How to find out all the Adam Numbers from 1 to 1000 using C programming!

#include <stdio.h>

#include <math.h>


void main (){

int i,j,m,n,x,Square_n,Rev_n = 0,Square_rev,Rev_Square = 0;

for(n= 1;n<=1000;n++){

Square_n = pow(n,2);

Rev_n = 0;

for(i=n;i>0;i/=10){

m = i % 10;

Rev_n = (Rev_n * 10) + m;

}

Square_rev = pow(Rev_n,2);

Rev_Square = 0;

for(j=Square_rev;j>0;j/=10){

x = j % 10;

Rev_Square = (Rev_Square * 10) + x; 

}

if(Square_n == Rev_Square){

printf("%d is an Adam Number\n",n);

}

}

Comments