forked from StartupInstitute/DevPreWork01
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |