Java program || Armstrong Number || while loop || Classes 9-10 || ICSE students

preview_player
Показать описание
Friends writing the program in the description shows " Metadata not saved " error.

So, I will upload the program in the comments section.

Hope you all understood the program 👍
Рекомендации по теме
Комментарии
Автор

Source code :

import java.util.*;
class Armstrong
{
int Fact( int n)
{
int f=1;
for(int i=n; i>=1; i--)
f=f*i;
return f;
}
public static void main ()
{
int s= 0, r=0, t=0;
Armstrong ob= new Armstrong();
Scanner sc = new Scanner( System.in);
System.out.println("Enter a number: ");
int n= sc.nextInt();
t = n;
while( n!=0)
{
r = n%10;
s = s+ ob.Fact(r);
n= n/10;
}
if ( t==s)
System.out.println(" Armstrong number");
else
System.out.println(" Not a armstrong number");
}
}

Hope you all understood the program 👍

Techni_Code
welcome to shbcf.ru