Skip to content

Instantly share code, notes, and snippets.

@cairesr
Created January 31, 2016 01:29
Show Gist options
  • Save cairesr/54da7b5f43fa7abb52d4 to your computer and use it in GitHub Desktop.
Save cairesr/54da7b5f43fa7abb52d4 to your computer and use it in GitHub Desktop.
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