
Hi.. Can any one tel how to watch a magic number of a program?

import java.util.*;
class MagicNumber{
public int divide(int x){
int a,b=0;
for(int i=x;i>0;i/=10){
a=i%10;
b+=a;
}
return b;
}
public static void main(String[]args)throws Exception{
Scanner input=new Scanner(System.in);
System.out.print("Enter the number: ");
int num =input.nextInt();
int b=0,x=1;
MagicNumber l=new MagicNumber();
do{
if(x==1){
b=l.divide(num); x++;
}
else{
b=l.divide(b);
}
}
while((b/10)>0);
if(b==1)
System.out.print("Magic Number");
else
System.out.print("Not a Magic Number");
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.