import java.io.*;
class keith_number
{
public static void meth()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter number");
int n=Integer.parseInt(br.readLine());
int temp=n,t=n,r,re=-1,a,b,c;
while(n>0)
{
r=n%10;
re++;
n=n/10;
}
b=temp%((int)Math.pow(10,re));
a=temp/((int)Math.pow(10,re));
System.out.println(a);
System.out.println(b) ;
while(true)
{
c=a+b;
System.out.println(c) ;
if(c>=t)
break;
a=b;
b=c;
}
if (c==t)
System.out.println("keith number");
else
System.out.println("not a keith number");
}
}
3 comments:
its wrong..tried both the examples of keith numbers,that is, 47 and 197.But the above program not working for 197 but perfectly fine for 47.Please see through it.
give me some explanation about how to find keith number
Post a Comment