1 / 2
Jul 2019

‘’’ I am constantly getting runtime error (NZEC) with the following code but when I tested the code on my machine, it worked perfectly. Can anyone tell where am I wrong or whats the correct solution to this problem (Python 3).

def check_prime(x):
chk=True
if x%2==0 and x!=2:
return False
if x<2:
return False
else:
for i in range(2,int(x/2)):
if x%i==0:
chk=False
return chk

def fun():
a = int(input())
b = int(input())
for i in range(a,b+1):
if check_prime(i):
print(i)
else:
continue
return True

def testcase():
x = int(input())
if x>10:
return False
for i in range(x):
fun()
return True

if name == ‘main’:
testcase()

  • created

    Jul '19
  • last reply

    Jul '19
  • 1

    reply

  • 677

    views

  • 2

    users