RE: Computation Contest #6 [2 SBI]

avatar
(Edited)

You are viewing a single comment's thread:

I am a bit late but here is my solution. The equations can written like x mod 9=-5, x mod 10=-5,
x mod 11=-5...
So we just need to look for the least common multiple of 9 10 ... 128 and subtract 5. That can be done for example by iteratively computing the lcm of 2 numbers I think . My answer is 13353756090997411579403749204440236542538872688049071995
The python code is below

def gcd(x, y): 
  
   while(y): 
       x, y = y, x % y 
  
   return x 
a = []  
for x in range(9,129):
    a.append(x)
lcm=1
for x in a:
    lcm=int(abs(lcm*x))//int(gcd(lcm,x))
    print(lcm%x,lcm)

for x in range(9,129):
    if((lcm-5)%x==x-5):
        pass
    else:
        print("Nope")
print(lcm-5)


0
0
0.000
0 comments