Skip to content

Commit

Permalink
finished problem StartupInstitute#5
Browse files Browse the repository at this point in the history
  • Loading branch information
adnissen committed Feb 27, 2014
1 parent 2698033 commit 22f9fe9
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions problem05.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
found = false
# start at this number since we know it has to be higher than that
index = 2520

def checkNum(num)
# just quick shortcuts to speed up the process 4x
if num % 2 != 0 or num % 10 != 0
return false
end
# an alternate way would be to check for mod 1-20
# but I like this solution more, because it double checks everything
for i in 1...20
# debug line if you want to see the computer list out all the numbers
#puts "index: " + num.to_s + " i: " + i.to_s + " res: " + (num % i).to_s
if num % i != 0
return false
end
end
end

while !found
# just keep going until it makes it past the 'return false' and we're good
if checkNum(index) == false
index = index + 1
else
found = true
puts index
end
end

0 comments on commit 22f9fe9

Please sign in to comment.