-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFun21.java
More file actions
28 lines (23 loc) · 547 Bytes
/
Fun21.java
File metadata and controls
28 lines (23 loc) · 547 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
package fun;
public class Fun21 {
public static void main(String[] args) {
SumRange(2,5,8);//2+3+4+5+
}
public static void SumRange(int a,int b,int c){
int a1=0;
int b1=0;
if (a<b ){
for (int i = a; i <=b; i++) {
a1+=i;
}
if (b<c){
for (int i = b; i <=c ; i++) {
b1+=i;
}
}
System.out.println(a1+b1);
}else {
System.out.println(0);
}
}
}