Write a program to check or find the armstrong number using Java

  To check whether the number is armstrong number or not, Before writing the java program let's discuss about what is the armstrong number ?

If the number is equal to the sum of cube of it’s own digit then it is called Armstrong Number.For example : Let’s take a number n=407.

x = 4*4*4 ( cube of it’s own place digit )
y = 0*0*0 ( cube of it’s own place digit )
z = 7*7*7 ( cube of it’s own place digit )

so, sum = x+y+z
sum = 64 + 0 + 343

sum = 407
The number n=407 is an Armstrong Number.

Table of Contents

Java Program Code

; Title: Java Program to check or find the armstrong-number.
; Author: codenaive littleboy8506@   
; Date:   13 Dec 2021
import java.util.Scanner;
public class Armstrong 
	public static void main(String[] arg)
		 Scanner obj =new Scanner(System.in);
		int a,b,c,d,sum,input;
	for(int i=1;i< =5;i++)    
     	System.out.println("Enter the number");
	  if(sum ==input)
			System.out.println(input+" is a Armstrong Number ");
			System.out.println(input+" is not a Armstrong Number");

Leave a Reply

Your email address will not be published. Required fields are marked *