-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsum.java
More file actions
executable file
·38 lines (16 loc) · 814 Bytes
/
sum.java
File metadata and controls
executable file
·38 lines (16 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.util.Scanner;
public class sum {
// the program will find the sum of the numbers to the given limit(n)
public static void main(String ar[]){
System.out.println("enter the the number");
Scanner s=new Scanner(System.in); {
int n=s.nextInt();
int sum=0;
for(int i=1;i<=n;i++)
{
sum=sum+i;
}
System.out.println("result:"+sum);
}
}
}