ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1068. Sum

Java 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 (: