write a program to compute the smallest number notes that will combine to give rs N. as notes are re1 rs2 rs5 rs10 rs 50 rs 100
Question
Write a program to compute the smallest number notes that will combine to give Rs N.
As notes are:
- Rs 1
- Rs 2
- Rs 5
- Rs 10
- Rs 50
- Rs 100
Solution
Sure, here is a Python program that calculates the smallest number of notes that will combine to give a certain amount:
def calculate_notes(N):
notes = [100, 50, 10, 5, 2, 1]
note_counter = [0, 0, 0, 0, 0, 0]
print ("Currency Count -> ")
for i, j in zip(notes, note_counter):
if N >= i:
j = N // i
N = N - j * i
print (i ," : ", j)
# Driver function
amount = 868
calculate_notes(amount)
In this program, we first define the denominations of the notes in the notes
list. We then create a note_counter
list to keep track of the number of notes of each denomination.
We then iterate over each denomination, starting from the highest. For each denomination, we calculate how many notes of that denomination we can use without exceeding the total amount. We then subtract the value of these notes from the total amount.
Finally, we print out the number of notes of each denomination that we used.
You can replace 868
with any amount you want to calculate the notes for.
Similar Questions
How many different sums of money can be formed from the four type of notes Rs 10, Rs 20, Rs 50 and Rs 100 ?
Given a positive integer n, find the smallest integer which has exactly the same
Find the smallest number such that when divided by 12, 18, 21 and 28, it leaves remainder 3 in each case?a.1012b.1010c.1011d.1009
Build the generator primes() function so that you fills the n one at a time, and comes back to primes() function until n > 100.
Determine the smallest digit number which is exactly divisible by 66, 99 and 1212.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.