between 1000 to 9999 only a single number(1729) satisfies both two properties. here is a 'C' Program to find the number.

#include #include

main() { long x,y,rem,sum,sum1,t,rev,div,flag;

for (x=100;x<=99999;x++) { t=x;sum=0; while(t>0) { rem=t%10; sum=sum+rem; t=t/10; } y=sum;rev=0; while(sum>0) { rev=rev*10+(sum%10); sum=sum/10; } if(x==y*rev) { rev=0;sum=x; while(sum>0) { rev=rev*10+(sum%10); sum=sum/10; } div=2;sum1=1;flag=0; while(rev>1) { if(rev%div==0) { rev=rev/div; if(flag==0){ sum1=sum1+(div*div);flag++;} } else { div=div+1; flag=0; } } sum1=sum1/2; printf("x=%d lastno=%d\n",x,sum1); } } getch();

More information about formatting options

## the mystery number

between 1000 to 9999 only a single number(1729) satisfies both two properties. here is a 'C' Program to find the number.

#include

#include

main()

{

long x,y,rem,sum,sum1,t,rev,div,flag;

for (x=100;x<=99999;x++)

{

t=x;sum=0;

while(t>0)

{

rem=t%10;

sum=sum+rem;

t=t/10;

}

y=sum;rev=0;

while(sum>0)

{

rev=rev*10+(sum%10);

sum=sum/10;

}

if(x==y*rev)

{

rev=0;sum=x;

while(sum>0)

{

rev=rev*10+(sum%10);

sum=sum/10;

}

div=2;sum1=1;flag=0;

while(rev>1)

{

if(rev%div==0)

{

rev=rev/div;

if(flag==0){

sum1=sum1+(div*div);flag++;}

}

else

{

div=div+1;

flag=0;

}

}

sum1=sum1/2;

printf("x=%d lastno=%d\n",x,sum1);

}

}

getch();