This is a Java program for armstrong number. But what is an armstrong number?

An armstrong number is onw whose sum of the cube of digits is the number itself.

**Example #1:** 153 ; 1^{3} + 5^{3} + 3^{3} = 1+ 125 + 27 = 153 (Hence Armstrong)

**Example #2: **370 ; 3^{3} + 7^{3} + 0^{3} = 27 + 343 + 0 = 370 (Hence Armstrong)

* Important*: There exist only 5 Armstrong numbers:

**1, 153, 370, 371, 407**

// Java program for armstrong number using recursion; import java.util.*; class armstrong { public static void main(String args[]) { armstrong obj= new armstrong(); int i,n,sum,m; Scanner sc=new Scanner(System.in); System.out.print("Enter a number : "); n=sc.nextInt(); // To read a number from the user. m=obj.checknum(n); // The sum of cubes of digit will be stored in variable m. if(n==m) // If sum of the cubes of a number(m) equals the number itself then it is a armstrong number. System.out.println("It is a armstrong number"); else System.out.println("Not a armstrong number"); } int checknum(int n) // This function will return the sum of the cubes of the digits of a number { if(n==0) return 0; else return (int)Math.pow(n%10,3)+ checknum(n/10); } }

OUTPUT: