You are viewing a single comment's thread from:

#### RE: Computation Contest #6 [2 SBI]

in #programming2 years ago (edited)

So if I'm right, one solution for all equations is `x = !128/!8-5` as the right side is always 5 smaller then the divider on the right side and the equations cold be rewritten as `x+5 mod d = 0` so 9 to 128 have to divide x+5. When multiplying all the dividers together, the result can be divided by all of them and is exactly 5 bigger than x.
But this obviously is not the smallest number, because many numbers from 9 to 128 are multiples (e.g. 9 and 18) so we only need to multiply with the biggest multiple below 129.
My program simply tests if x is a multiple of the divider. If it's not, it multiplies x to the divider making it a divider. This procedure is repeated with dividers from 128 to 9 downwards.

``````x = 1
while True:
for i in range(128, 8, -1):
if x % i == 0:
pass
else:
x *= i
break
else:
x -= 5
break
``````

So `x = 3692046484038964353473548580043636599281147520791807426559995`