Skip to content

Instantly share code, notes, and snippets.

@deatheragetr
Created June 21, 2013 13:22
Show Gist options
  • Save deatheragetr/5831084 to your computer and use it in GitHub Desktop.
Save deatheragetr/5831084 to your computer and use it in GitHub Desktop.
smallest number divisible by every number between 1 and 20
def smallest_divisible
check = 40
i = 2
divisible_by_all = false
while !divisible_by_all && i <= 20
remainder = check % i
if remainder == 0 && i == 20
divisible_by_all = true
elsif remainder != 0
check += 1
i = 2
else
i += 1
end
end
puts check
end
the answer is 232792560
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment