#include stdio.h
main (int argc, char **argv)
{
long inx, num, n, ns, r1, r2;
num = atol(argv[1]);
printf("num=%ld\n", num);
for (inx = 1; inx < num; inx++)
{
n = inx;
ns = n*n;
while (n > 0)
{
r1 = n%10;
r2 = ns%10;
if (r1 != r2) break;
n = n/10;
ns = ns/10;
}
if (n == 0)
{
printf("%ld is automorphic\n", inx);
}
}
}
No comments:
Post a Comment