[Solved] finding emrips with python, what am i doing wrong?


There are a lot of issues with your code. I altered the function isPrime. There is among other no need for count here and if you want to increment test by 1 every loop use test +=1:

def isPrime(value):
test = 2
while(test < value):
    if( value % test != 0):
        test +=1
    else:
        return 0
return 1

There is an easy way to reverse digits by making value a string in reversed order and to convert this into an integer:

def reverse(value):
    return int(str(value)[::-1])

You among other have to assign the input to i. n in your code is a constant 5. You have to increment i by one in any condition and increment the count by one if i is an emirp only:

i = int(input("Please enter a positive number: "))
count = 0
while(count < 5):  
    if(isPrime(i)):
        if(isPrime(reverse(i))):
                print(str(i) + "\n")
                count += 1
                i += 1
        else:
            i += 1
    else:
        i +=1

2

solved finding emrips with python, what am i doing wrong?