test/Sum.java

25 lines
221 B
Java

public class Sum {
public static void main(String[] args) {
int n;
int s;
int i;
n = 4;
s = 0;
i = 1;
while(i <=n) {
s = s + i;
i = i + 1;
}
System.out.println(s);
}
}