Archive

Posts Tagged ‘very very large numbers’

Find the GCD of two very very large numbers

July 20, 2010 2 comments

Yes this is possible . Thank you python 🙂

t = int(raw_input())
while t:
    s = raw_input()
    a,b = [long(i) for i in s.split(' ')]
    while b :
        a,b = b,long(a%b)
    print a
    t =t - 1

Explanation:

The above code takes input of the number of tries you want to carry
out i.e ( t )
and then it accepts the numbers separated by a space
i.e 123123123123123 123123123123123123123123123
simple isn’t it? Yes …

Sample Input
1
123123123123 123123123123123123

Sample Output
123123