Skip to content

pavithrakuricheti534/Armstrong-number

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Armstrong-number

/* Lab 2.3Write a program to verify whether the number is Armstrong or not.*/

import java.util.Scanner;

class ArmstrongNumber

{

public static void main(String args[])	{

	int n,a,r,sum=0;

	Scanner s=new Scanner(System.in);

	System.out.print("Enter a number: ");

	n=s.nextInt();

	a=n;

	while(n!=0)

	{

		r=n%10;

		sum=sum+(r*r*r);

		n=n/10;

	}

	if(sum==a)

	{

		System.out.format("%d is a armstrong number",n);

	}

	else

	{

		System.out.format("%d is not a armstrong number",n);

	}

}

}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published