Automorphic Number is a number whose last digits of square of the number is equal to the original number.
Example 1: 25. 252 = 625. We observe that the last two digits of 625 is 25 which is equal to the original number. Hence it is an Automorphic Number.
Example 2: 6. 62 = 36. We observe that the last digit of 36 is 6 which is equal to the original number. Hence it is an Automorphic Number.
Example 3: 12. 122 = 144. Here the last two digits of 144 is not equal to the original number. Hence it is not an Automorphic Number.
C
#include <stdio.h>
#include <math.h>
int main()
{
int n=0,r=0,nCopy=0,count=0;
printf("Enter a number: ");
scanf("%d",&n);
nCopy=n;
while(n>0)
{
count++;
n=n/10;
}
n=nCopy;
r=(n*n)%(int)pow(10,count);
if(n==r)
{
printf("%d is an Automorphic Number",n);
}
else
{
printf("%d is not an Automorphic Number",n);
}
return 0;
}C