JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.util.Scanner;
public class Program {
public static void main(String[] args) {
//your code goes here
Scanner sc = new Scanner(System.in);
int sum = 0;
int num = sc.nextInt();
while(num > 0){
sum += num;
num--;
}
System.out.println(sum);
}
}
//trying to get it to input 4 to output 10 and 42 to output 903
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run