-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStrongNo.java
More file actions
39 lines (31 loc) · 809 Bytes
/
StrongNo.java
File metadata and controls
39 lines (31 loc) · 809 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
import java.util.*;
public class Main{
public static void main(String[] args) {
System.out.println("Enter the number: ");
Scanner scan = new Scanner(System.in);
int inputNumber = scan.nextInt();
int i;
int factorial,digit;
int sum = 0;
int temp = inputNumber;
while(temp!=0){
i=1;
factorial=1;
digit=temp%10;
while(i<=digit){
factorial= factorial*1;
i++;
}
sum = sum + factorial;
temp= temp/10;
}
if(sum == inputNumber){
System.out.println(inputNumber + " is a strong number\n");
}
else{
System.out.println(inputNumber + " is not a strong number\n");
}
}
}
/**
* @author Pradumn Patel */