-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArmStrongNumber.java.bak
More file actions
53 lines (43 loc) · 1.03 KB
/
ArmStrongNumber.java.bak
File metadata and controls
53 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
import java.util.Scanner;
class ArmStrongNumber
{
public static void main(String[] args)
{
Scanner s= new Scanner(System.in);
System.out.println("---- Program will Print ARMSTRONG NUMBER of given range");
System.out.println("Enter Start number :" );
int start = s.nextInt();
System.out.println("Enter End number :" );
int end = s.nextInt();
for (int temp=start;start<=end ;start++ )
{
int sum = 0;
int prod = 1;
int count = 0;
for (int j=start;j>0 ;j=j/10 )
{
int digit = j%10;
count++;
}
System.out.println("count "+count);
for (int i=start;i>0 ;i=i/10 )
{
int digit = i%10;
System.out.println("i "+digit);
int fact = 1;
int pow = count;
for (int k=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 );
}
}
}
}