We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I don't know why only the first case works even after using the standard gcd function and the euclidean algorithm. Please guide.
from fractions import gcd
N,a,b = raw_input().strip().split(' ')
a,b = [long(a),long(b)]
##def hcf(x, y):
## while(y):
## x, y = y, x % y
## return x
temp = N * a
temp=temp.replace(" ","")
temp=long(temp)
x = N*b
x=x.replace(" ","")
x=long(x)
print gcd(temp,x)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
GCD Exploration
You are viewing a single comment's thread. Return to all comments →
I don't know why only the first case works even after using the standard gcd function and the euclidean algorithm. Please guide.