Skip to main content

Featured

functions in Python

C++ program to display automorphic numbers between 1 to 1000

/* Program to display automorphic numbers between 1 to 1000. An Automorphic number is that whose square has that number in it from back. For Example: 25 the square of 25 is 625 which has 25 in it */ 
#include<iostream.h>
long digcount(long);
void main()
{
for(long i=1;i<=1000;i++)
{
long ten=1;
long sq=i*i;
long dc=digcount(i);
for(int k=1;k<=dc;k++)
{
ten=ten*10;
}

if(sq%ten==i)
cout<<"Automorphic Number "<<i<<"\n";
}
}

long digcount(long x)
{
long count=0;
 while(x>0)
 {
x=x/10;
++count;
  }
return count;
}

OUTPUT: 

Comments

Popular Posts