1 / 7
Jan 2015

my both code giving run time erroe(NZEC)
from fractions import gcd
t=int(input())
for i in range(t):
a,b=map(int,raw_input().split())
x=gcd(a,b)
print (x)

and another one

def gcd(n1,n2):
if(n2==0):
return n1
elif(n1==0 and n2==0):
return 0
else:
return gcd(n2,n1%n2)
t=int(input())
for i in range(t):
n1,n2=map(int,raw_input().split())
x=gcd(n1,n2)
print (x)
how to fix this error??

  • created

    Jan '15
  • last reply

    Jan '15
  • 6

    replies

  • 593

    views

  • 3

    users

  • 1

    link

i am new in this forum, can you tell me what is code tag??

def gcd(n1,n2):
        if(n2==0):
            return n1
        else:
            return gcd(n2,n1%n2)
t=int(input())
for i in range(t):
    n1,n2=map(int,raw_input().split())
    print (gcd(n1,n2))

Which judge did you submit this to? When I tried to run your code on Ideone using the Python 3 compiler I got the error:

Traceback (most recent call last):
  File "./prog.py", line 9, in <module>
NameError: name 'raw_input' is not defined

I'm not really a python user. Maybe I'll move this off to the Python group so that numerix will see it.

This problem shouldn't be allowed for Python languages, nor any other with bigNum library.