Created
May 23, 2015 23:25
-
-
Save barreyro/a0c0f67729e54b2fac05 to your computer and use it in GitHub Desktop.
Have the function CoinDeterminer(num) take the input, which will be an integer ranging from 1 to 250, and return an integer output that will specify the least number of coins, that when added, equal the input integer. Coins are based on a system as follows: there are coins representing the integers 1, 5, 7, 9, and 11. So for example: if num is 1…
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 CoinDeterminer(num) | |
return num if num < 5 | |
count = num / 11 | |
if (num%11).even? | |
return count + 2 | |
else | |
return count + 1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
2