|
|
back to boardDiscussion of Problem 1068. SumJava Accepted Posted by hostpol 31 Oct 2019 02:05 import java.util.Scanner; public class Main { public static void main(String[] args) { int c = 0; Scanner n = new Scanner(System.in); int f = n.nextInt(); n.close(); if (f > 0) { for (int i = 1; i <= f; i++) c += i; System.out.println(c); } else if (f <= 0) { for (int i = f; i <= 1; i++) c += i; System.out.println(c); } } } Re: Java Accepted Posted by Sergey 13 Jan 2023 19:45 Edited by author 13.01.2023 20:21 Re: Java Accepted Posted by Ehab 20 Nov 2023 02:25 Man just use MATH (: |
|
|