-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrongNum.java
More file actions
41 lines (35 loc) · 814 Bytes
/
strongNum.java
File metadata and controls
41 lines (35 loc) · 814 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
import java.util.Scanner;
public class strongNum
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int r;
int fact;
int strong=0;
int temp=n;
while(n!=0)
{
r=n%10;
fact=factorial(r);
strong=strong+fact;
n=n/10;
}
//System.out.println(strong);
if(temp==strong)
{
System.out.println("Number is strong");
}
else
System.out.println("Not Strong");
}
public static int factorial(int n)
{
int f=1;
for(int i=1;i<=n;i++)
{
f=f*i;
}
return f;
}
}