- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArmStrongNumber.java
More file actions
Latest commit
54 lines (43 loc) · 1.03 KB
/
Copy pathArmStrongNumber.java
File metadata and controls
54 lines (43 loc) · 1.03 KB
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
54
importjava.util.Scanner;
classArmStrongNumber
{
publicstaticvoidmain(String[] args)
{
Scanners= newScanner(System.in);
System.out.println("---- Program will Print ARMSTRONG NUMBER of given range");
System.out.println("Enter Start number :" );
intstart = s.nextInt();
System.out.println("Enter End number :" );
intend = s.nextInt();
for (inttemp=start;start<=end ;start++ )
{
intsum = 0;
intcount = 0;
for (intj=start;j>0 ;j=j/10 )
{
intdigit = j%10;
count++;
}
System.out.println("count "+count);
for (inti=start;i>0 ;i=i/10 )
{
intprod = 1;
intdigit = i%10;
System.out.println("i "+digit);
intfact = 1;
intpow = count;
for (intk=digit ;pow>0 ;pow-- )
{
prod = prod*digit;
}
System.out.println("prod "+prod);
sum = sum + prod;
System.out.println("sum "+sum);
}
if (start == sum)
{
System.out.println("ArmStrong Number is : "+start );
}
}
}
}