|
|
back to boardDiscussion of Problem 1068. SumCould you please tell me what's am wrong? import java.util.*; public class Sum2 { public static void main(String[] args) { Scanner sc= new Scanner(System.in); int x=sc.nextInt(); int sum=0; if(x<=0){ for(int i=x;i<=1;i++){ sum+=i; } System.out.println(sum); } else if(x<10000){ for(int i=1;i<=x;i++){ sum+=i; } System.out.println(sum); }
} } |
|
|