-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathamstrong.java
More file actions
52 lines (45 loc) · 766 Bytes
/
Copy pathamstrong.java
File metadata and controls
52 lines (45 loc) · 766 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
43
44
45
46
47
48
49
50
51
52
/*find factorial, find amstrong or not?*/
import java.util.*;
class amstrong
{
private static void main(String[] args)
{
int b,c,d=0;
int x=10;
int y=12;
Scanner ams=new Scanner(System.in);
System.out.println("Enter the number");
int a=ams.nextInt();
int e=a;
for(int i=1;i<=3;i++)
{
b=a/10; c=a%10;
a=b;
d=d+(c*c*c);
}
System.out.println(d);
if(d==e)
{
System.out.println("It's Amstrong number");
}
else
{
System.out.println("It's not Amstrong number");
}
}
}
class factorial
{
public static void main(String[] args)
{
Scanner fac=new Scanner(System.in);
System.out.println("Enter the number");
int ab=fac.nextInt();
int ba=ab;
while(ba>1)
{
ab=ab*(--ba);
}
System.out.println("Factorial is "+ab);
}
}