|
|
вернуться в форумWhat Wrong? import java.util.Scanner; import java.io.*; public class HelloWorld { public static void main(String args[]) {
int a = 0; int total = 0; Scanner input = new Scanner(System.in); a = input.nextInt(); total = convertFunc(a); System.out.println(total); }
public static int convertFunc(int n){
int sum = 0; if(n > 0 && n <= 10000 ) { for(int i = 1 ; i <= n ; i++ ) { sum += i; } } else { for(int i = 1 ; i >= n ; i--) { sum += i; } } return sum; } } |
|
|