# Python Program to Generate Automorphic (Cyclic) Numbers

#### This python program generates Automorphic numbers in an interval given by user. Automorphic number is also known as Cyclic number.

A number is called Automorphic or Cyclic number if and only if its square ends in the same digits as the number itself.

Automorphic or Cyclic Number Examples: 52 = 25, 62 = 36, 762 = 5776, 3762 = 141376

## Python Source Code: Generate Automorphic (Cyclic) Numbers

``````
# Generate Perfect numbers in interval

# Function to Check Automorphic
def is_automorphic(n):
square = n * n

while n:
square_remainder = square%10
number_remainder = n%10

if square_remainder != number_remainder:
return False

n //= 10
square //= 10

return True

min_value = int(input('Enter minimum value: '))
max_value = int(input('Enter maximum value: '))

# Looping & displaying if it is Automorphic
# Here min_vale & max_value are included
print('Automorphic numbers from %d to %d are:' %(min_value, max_value))
for i in range(min_value, max_value+1):
if is_automorphic(i):
print(i, end=' ')
``````

## Automorphic Generation: Output

```Enter minimum value: -100
Enter maximum value: 10000
Automorphic numbers from -100 to 10000 are:
0 1 5 6 25 76 376 625 9376
```

## Automorphic Generation: Code Explanation

We first read min_value and max_value from user. Function `is_automorphic()` is used to check whether a given number is Automorphic or not. We loop from `min_value` to `max_value` and pass each number to `is_automorphic()` function. If this function returns `True`, then we print it.