RE: Code with a language you don't know 07-16-2018, 07:22 AM
#11
(07-16-2018, 07:16 AM)Vi-Sion Wrote:(07-16-2018, 07:14 AM)Percent Wrote:Code:public static long factorial(long i) { // Base case if i == 1; algorithm otherwise return i == 1 ? 1 : n * (factorial(n-1)); }
If @reGEN approve your solution,it's up to you to post a new simple exercise.
Next exercise: Your task is to take an inputted amount of money (for example, $0.60 or $1.25), and calculate the minimum amount of coins necessary to correspond to this inputted value.
Coins available are pennies (0.01), nickels (0.05), dimes (0.1), and quarters (0.25). Toonies and loonies may be included but are not necessary. For example, if I inputted "$0.83", the minimum amount of coins needed would be 7 coins; 3 quarters (0.75), 1 nickel (0.80), and 3 pennies (0.83). Calculate that coin number.

![[+]](https://sinister.li/images/modern/collapse_collapsed.png)






