import numpy as np
from matplotlib import pyplot as plt
from matplotlib import style
%matplotlib inline

style.use('bmh')
style.use('dark_background')

a = 13; N = 15; num_iter = 15

# Finding the period
values = []
for x in range(num_iter):
    values.append((a**x) % N)
    
print(values)

plt.plot(values)

start = values[0]
period = 0

for i in range(1, len(values)):
    if values[i] == start:
        period = i
        break
        
print('Period:', period)

a = 18; N = 77; num_iter = 80

# Finding the period
values = []
for x in range(num_iter):
    values.append((a**x) % N)
    
print(values)

plt.plot(values)

start = values[0]
period = 0

for i in range(1, len(values)):
    if values[i] == start:
        period = i
        break
        
print('Period:', period)

