Mock Vita Prime fibonocci program

Can anyone tell me why i got this as wrong answer?

def isPrime(num):  #function to check for prime Number
    if(num>1):
        flag=0
        for i in range(2,num):
            if(num%i==0):
                flag=1
                break
        if(flag==0):
            return True  #it  is a prime number
        else:
            return False
    else:
        return False
n,m=map(int,input().split())
first=[int(x) for x in range(n,m) if (isPrime(x))] #first list that contains prime numbers between n and m
second=[]
for i in first:
    for j in first:
        if(i!=j):
            second.append(str(i)+str(j))
prime=list(set([int(x) for x in second if isPrime(int(x))]))
a=min(prime)
b=max(prime)
fib=[a,b]
for i in range(len(prime)-2):
    c=a+b
    a=b
    b=c
    fib.append(c)
print(fib[len(prime)-1])

This program works fine in Java, but gives Wrong Answer in Python. This is because while finding the fibonacci in java, after a certain limit we start getting negative numbers because of the range of integer, whereas this is not the case with Python. There is no particular range in Python. hence to find out the correct o/p of this program in python, you should divide the final answer by 2^64-1.

Thanks for helping me out.But I didn’t get the concept😢

I am getting the same error bro…!! In python WA shows up.

1 Like

could explain it a bit more…?