Skip to content

Instantly share code, notes, and snippets.

View gm50x's full-sized avatar
🐺
Rise and rise again until lambs become lions!

Getulio Magela Silva gm50x

🐺
Rise and rise again until lambs become lions!
View GitHub Profile
/**
* PROBLEM: Change
* You are writing a change calculating algorithm that will
* determine the proper change with the smallest possible amount
* of coins and bills.
* For the problem, consider you have:
* - Bills: 100, 50, 20, 10, 5 and 2
* - Coins: 1, 0.5, 0.25, 0.10, 0.05 and 0.01
*
* Enough talk... Get coding!
/**
* Demonstrating Imprecision
*/
let n = 1.22
while (n && n > 0) {
let m = n;
n = n - 0.01
console.log(`${m} - ${0.01} = ${n}`)