Skip to content

Instantly share code, notes, and snippets.

@Zodik09
Last active May 13, 2025 12:37
Show Gist options
  • Save Zodik09/71000b735b9466cfbb51c78941c74929 to your computer and use it in GitHub Desktop.
Save Zodik09/71000b735b9466cfbb51c78941c74929 to your computer and use it in GitHub Desktop.
57. You need to write a program where the user inputs an amount in Indian Rupees, and the program should output the number of currency notes required to make up that amount using the largest denominations first. Denominations Available (Indian Rupees): ₹2000, ₹500, ₹200, ₹100, ₹50, ₹20, ₹10, ₹5, ₹2, ₹1 // Example 1: // Input: // Amount: 4327 // …
var prompt = require("prompt-sync")();
let rupees = Number(prompt("Enter the amount: "));
let money = [2000, 500, 200, 100, 50, 20, 10, 5, 2, 1];
for (const note of money) {
let count = Math.floor(rupees / note)
rupees %= note;
console.log(`₹${note} X ${count}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment