forked from AkhzarFarhan/HactoberFest-2025
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharmstrong.java
More file actions
36 lines (33 loc) · 708 Bytes
/
armstrong.java
File metadata and controls
36 lines (33 loc) · 708 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
package newstart;
import java.util.Scanner;
public class armstrong {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number");
int n = sc.nextInt();
int f=n;
int sum=0;
if(n==0)
{
System.out.println("Armstrong number");
}
else
{
while(n!=0)
{
int a = n%10;
sum += a*a*a;
n=n/10;
}
if(sum==f)
{
System.out.println("Armstrong number");
}
else
{
System.out.println("Not an Armstrong number");
}
}
}
}