osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

3 random numbers


So I was given this question to be solved in Python 3 : Pick any 3 random ascending numbers and write out a loop function that prints out all 3 numbers. This was the code and solution presented to me. Can anyone understand it and explain it to me please ? I have looked at it but cannot see how it was derived and why the correct solution was printed. Thanks alot !

# any 3 ascending numbers , counter must start at 0. 
# 400 467 851
i = 0
x = 400
while x < 852:
print(x)
if i > 0:
x = x + ((i + 4) * 67) + (i * 49)
else:
x = x + 67
i = i + 1