- NEON NUMBERS:
Im gonna do a program on neon number. Neon number is nothing but a number where the sum of digits of square of the number is equal to the number.
for example:
9power9 =81. here, 9 to the power 9 is 81 also 81 is drived as 8+1=9 bithe the ans are are then it is called neon number.
Program:
class Neon{
public static void main(String args[]){
int n=10;
int result=n*n;
int i=0;
int a=0;
while(result>0){
a=result%10;
i=i+a;
result=result/10;
}
if(n==i){
System.out.println(“Neon”);
}
else{
System.out.println(“not Neon”);
}
}
}
output:
sobhika@sobhika-HP-Laptop-15-db1xxx:~$ javac Neon.java
sobhika@sobhika-HP-Laptop-15-db1xxx:~$ java Neon
not Neon
sobhika@sobhika-HP-Laptop-15-db1xxx:~$
ARMSTRONG NUMBER:
Armstrong number is nothing but one whose sum of digits raised to the power three equals the number itself. 371, for example, is an Armstrong number because 3**3 + 7**3 + 1**3 = 371.
Program:
class Armstrong{
public static void main(String args[]){
int n=153;
int m=n;
int c=0;
int res;
while(n>0){
res=n%10;
c=c+(resresres);
n=n/10;
}
if(m==c){
System.out.println(“Armstrong”);
}
else{
System.out.println(“not a Armstrong”);
}
}
}
sobhika@sobhika-HP-Laptop-15-db1xxx:~$ javac Armstrong.java
sobhika@sobhika-HP-Laptop-15-db1xxx:~$ java Armstrong
Armstrong
sobhika@sobhika-HP-Laptop-15-db1xxx:~$