Check prime or non prime

def isPrime(n) :

if (n <= 1) :  
    return False
if (n <= 3) :  
    return True

if (n % 2 == 0 or n % 3 == 0) :  
    return False

i = 5
while(i * i <= n) :  
    if (n % i == 0 or n % (i + 2) == 0) :  
        return False
    i = i + 6

return True

n = int(input())
if(isPrime(n)) :
print(“Prime”)
else :
print(“Not Prime”)

above code is working on gfg while on cb m getting err
Traceback (most recent call last):
File “script.py”, line 19, in
n = int(input())
EOFError: EOF when reading a line

why so

Hey @shivani_jainEtW, when you are running your codes on ide, before pressing the run button you need to provide the custom input. So to do this, click on input button on top left, (if working on cb.lk/ide) or search for button named ‘custom input’ than press run.

Hope this resolved your doubt. :blush:

1 Like