pull down to refresh

We can test all numbers until we find one that is divisible by every number from one to twenty. Brute force method.

number = 1
found = false

while ( not found )
--found = true

--for ( i = 1 until i = 20 )
----if ( number / i diff 0 )
------found = false
------stop

reply

I don't think works. as written it will stop on i = 2 with found = false and number = 1

reply

The stop only breaks the for loop, the while loop keeps going. No?

reply

then i think it'll run forever because number does not iterate

reply

lmao. This is an algorithm, it isn't written in any programming language.
I can't code, but Gemini turned my algorithm into Python for me. Ahah

number = 1
found = False

while not found:
found = True

for i in range(1, 21):
if number % i != 0:
found = False
break

if not found:
number += 1

print(f"n = {number}")

reply