Sunday, July 04, 2010

Strange number generation

Buzz It
import java.io.DataInputStream;
class strange
{
public static void main(String args[])
{ int limit=0;
DataInputStream in=new DataInputStream(System.in);
try
{ System.out.println("limit");
limit=Integer.parseInt(in.readLine());
}
catch(Exception e)
{
}
for(int i=1;i<limit;i++)
{ int temp=i; int sum=0;
while(temp>0)
{
int c=temp%10;
sum=sum+c*c*c;
temp=temp/10;
}
if(i==sum)
{
System.out.println(i);
}

}
}
}
OUTPUT

0 comments:

Post a Comment