-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStrongNumber.java.bak
More file actions
53 lines (39 loc) · 957 Bytes
/
StrongNumber.java.bak
File metadata and controls
53 lines (39 loc) · 957 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
47
48
49
50
51
52
53
import java.util.Scanner;
class StrongNumber
{
public static void main(String[] args)
{
Scanner s1 = new Scanner(System.in);
System.out.println("---- PROGRAM WILL PRINT STRONG NUMBER OF GIVEN RANGE -----");
System.out.println("Enter starting number :");
int start = s1.nextInt();
System.out.println("Enter ending number :");
int end = s1.nextInt();
int sum = 0;
for (int temp=start;start<end ; start++ )
{
sum = 0;
for (int i=start ;i>0; i=i/10)
{
int digit = i%10;
//System.out.println("Digit : "+digit);
int fact = 1;
for (int j=digit; j>0;j-- )
{
fact = fact*j;
//System.out.println("fact : "+fact);
}
sum = sum + fact;
//System.out.println("sum : "+sum);
}
if(sum==start)
{
System.out.println("STRONG NUMBER "+sum);
}
else
{
System.out.println("Not a strong number :"+start);
}
}
}
}