-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA74.java
More file actions
46 lines (35 loc) · 774 Bytes
/
A74.java
File metadata and controls
46 lines (35 loc) · 774 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
39
40
41
42
43
44
45
46
import java.util.Scanner;
class A74
{
public static void main(String[] args)
{
Scanner s= new Scanner(System.in);
System.out.println("---- Program will Print sum of digits of PRIME NUMBER in given range ----");
System.out.println("Enter start number :" );
int start = s.nextInt();
System.out.println("Enter end number :" );
int end = s.nextInt();
while(start<=end){
int i =2;
while(i<start){
if (start%2 == 0)
{
break;
}
i++;
}
if(start == i)
{
int sum = 0;
while (i>0)
{
int digit = i%10;
sum = sum + digit;
i = i/10;
}
System.out.println(" sum of each digit prime number is :"+sum);
}
start++;
}
}
}