In Mathematics an automorphic number (sometimes referred to as a circular number) is a number whose square ends in the same digits as number itself.
For example, 52 = 25, 762 = 5776
#include <iostream.h>
#include <conio.h>
void main(){
int n, d;
long sq;
cout << "\n Enter a Number :";
cin >> n ;
sq =(long) n * n ;
int y, r;
long x = sq;
y = n;
while(y!=0)
{
r= y%10;
d = (int) (x%10);
x = x/10;
y = y/10;
if(r ! = d)
cout << " \ n NOT an Automorphic Number.";
getch();
exit(1);
}
cout << " \ n an Automorphic Number.";getch();
}
No comments:
Post a Comment