NEON Number program:
public class Neonno {
void add(int num){
int square=num*num;
int sum=0;
while(square>0) {
int rem=square%10;
sum=sum+rem;
square=square/10;
}
if(num==sum) {
System.out.println(“This is NEON number”);
}
else {
System.out.println(“Not a NEON number”);
}
}
public static void main(String[] args) {
Neonno n1=new Neonno();
n.add(9);
}
OUTPUT:
This is NEON number
LEAST COMMON MULTIPLE(lcm):
public class Lcm {
void add(int n1,int n2) {
int big=n1>n2 ? n1:n2;
while(true) {
if(big%n1==0 && big%n2==0) {
System.out.println(big + ” is the least common multiple of 12,9 ”);
break;
}
big=big+1;
}
}
public static void main(String[] args) {
Lcm l1=new Lcm();
lcm.add(12,9);
}
}
OUTPUT:
36 is the least common multiple of 12,
Perfect number:
public class Prefectno {
void add(int num,int div,int sum){ while (div<num) { if (num % div == 0) { sum = sum + div; } div = div + 1; if (num == sum) { System.out.println(number+"IS A PREFECT NUMBER"); } else { System.out.println("NOT PREFECT NUMBER "); }} public static void main(String[] args) { Prefectno n1=new Prefectno(); n1.add(28,1,0); } |
}
OUTPUT :
28 IS A PREFECT NUMBER