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

WA#4
Posted by Marc 25 Mar 2012 23:54
import java.util.Scanner;
public class Bil {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = numbers (Math.abs(a));
        if (a >= 0 )System.out.println(b);
        else {System.out.println(-b);}
    }


    public static int numbers( int a){
        int sum = 0;
        if (a > 1){
            for (int i = 2; i <= a; i++)
            sum +=i;
            }
//        else if (a == 0) sum = 0;
        else{
            sum = 1;
            }
        return sum;
    }
}