-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYT53.java
More file actions
42 lines (35 loc) · 925 Bytes
/
YT53.java
File metadata and controls
42 lines (35 loc) · 925 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
/*Special Number? Ex: 145 = 1! + 4! + 5! = 1 + 24 + 120 = 145
*
*/
import java.io.*;
public class YT53 {
public static void main(String[] args)throws IOException
{
int n, d=0;
int r=0, fact=1, sum=0;
InputStreamReader I = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(I);
System.out.println("Enter the number? ");
n = Integer.parseInt(br.readLine());
d = n;
while(n>0)
{
r=n%10;
for (int i=1; i<=r; i++)
{
fact=fact*i;
}
sum = sum + fact;
n=n/10;
fact=1;
}
if (d==sum)
{
System.out.println("SPECIAL NUMBER");
}
else
{
System.out.println("Not SPECIAL NUMBER");
}
}
}