Created
January 31, 2016 01:29
-
-
Save cairesr/54da7b5f43fa7abb52d4 to your computer and use it in GitHub Desktop.
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
def virus_finder(n) | |
rest = n | |
total_five = 0 | |
total_three = 0 | |
while(rest >= 3 || rest >= 5) | |
if(rest % 3 == 0) | |
rest -= 3 | |
total_five += 3 | |
elsif(rest % 5 == 0) | |
rest -= 5 | |
total_three += 5 | |
else | |
rest -= 3 | |
total_five += 3 | |
end | |
if(rest == 0) | |
return "5" * total_five + "3" * total_three | |
end | |
end | |
-1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment