Skip to content
This repository was archived by the owner on Oct 1, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Language/Java/Armstrong.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//Program to check whether a number is an armstrong number or not.
//A positive integer is called an Armstrong number of order n if the sum of cubes of each digits is equal to the number itself.

import java.util.Scanner;

public class Armstrong {

public static void main(String[] args)
{
System.out.println("Enter any number: ");
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m, rem, res = 0;

m = n;

while(m!= 0)
{
rem = m % 10;
res+= Math.pow(rem, 3);
m /= 10;
}

if(res == n)
System.out.println(n + " is an Armstrong number.");
else
System.out.println(n + " is not an Armstrong number.");
}
}