1

Context: I was required to write a code to calculate the Fibonacci numbers and then decided to test them against $\mod m$ to see what will happen. The first $m$ that I tried was $m=5$ and for some reason it seems that $F_n \mod 5= 0$ if $n \mod 5 =0$. I thought at first that this must be a propriety of primes that $F_n \mod p= 0$ if $n \mod p =0$ (but I was wrong) so I wrote a code to test what $n$ make $F_n \mod m= 0$


print("Enter how many numbers of $F_n$ you want to calculate")
n=int(input ())
print("Enter m")
m=int(input ())
A=[1,1]
k=1
y=1
ss=1
if n <=2:
    if n==1:
        A=[1]
    else:
        A=[1,1]

for i in range (3, n+1):
k=k+y y=y+k A.insert(2(i-1)-1,k) if n%2==0 : if i== (n+2)//2: A.insert(2(i-1),y)
break else: if i==(n+3)//2: break

A.insert(2*(i-1),y) 

B=[] C=[] s=0 for j in range (0, n): B.insert(j, A[j]%m) if B[j]==0: C.insert(s,j+1) s=s+1

print(C)


It seems that for fixed $m$ the required $n$ such that $F_n \mod m= 0$ is always a all the multiples of certain $a_m \in \mathbb{N}$.

For example for $m=2$, $F_n \mod 2 =0 $ if $n \in \{3,6,9,15,18, \dots\}$ so $a_2=3$.

Here is the first $30$ of $a_m$ arranged in $(m,a_m)$:

(2,3), (3,4), (4,6), (5,5), (6,12), (7,8), (8,6), (9,12), (10,15), (11,10), (12,12), (13,7), (14,24), (15,20), (16,12), (17,9), (18,12), (19,18), (20,30), (21,8), (22,30), (23,24), (24,12), (25,25), (26,21), (27,36), (28,24), (29,14), (30,60), (31,30)

My questions are:

  • How do I calculate $a_m$ for all $m >1$?
  • Which positive integers $m$ have the property that $m=a_m$? In the first $30$ positive integers (excluding $1$), $m=5,12,25$ are the only ones with this property.

Here is a python code that can check for what $m$ have the property $m=a_m$


print("Enter the range of m")
l= int(input())
n=max(1000, 2*l)
A=[1,1]
k=1
y=1
if n <=2:
    if n==1:
        A=[1]
    else:
        A=[1,1]    
for i in range (3, n+1):
    k=k+y
    y=y+k
    A.insert(2*(i-1)-1,k)
    if n%2==0 :
        if i== (n+2)//2:
            A.insert(2*(i-1),y)          
            break
    else:
        if i==(n+3)//2:
            break
    A.insert(2*(i-1),y) 
for m in range (2, l):
    ss=1
    for j in range (0, n):
        if ss==-1:
            break
        if A[j]%m==0:
            if j+1!=m:
                ss=-1
                break
            elif j+1==m:
                print(m)
pie
  • 8,483

0 Answers0