#include<iostream.h>
#include<math.h>
#include<conio.h>
void main()
{
long int x,s,a,n,num;
clrscr();
cout<<"up to which number\n";
cin>>n;
cout<<"strange numbers up to \t"<<n<<" are:\n";
for(num=1;num<=n;++num)
{
s=0;
x=num;
while(x>0)
{
a=x%10;
s=s+pow(a,3);
x=x/10;
}
if(num==s)
cout<<num<<"\t";
}
getch();
}
OUTPUT:
up to which number
4000
strange numbers up to 4000 are:
1 153 370 371 407
0 comments:
Post a Comment