### Q1 Can the value be handed out with 20 and 50 notes

As already noted this can be checked if the value can be divided without remainder by a combination of notes. This is obviously true if the value is a multiple of 20 or 50, or the value is a multiple of 10 with an additional condition. The additional condition is here a value of greater or equal than 70. To prove this write down a table:

10 - no

20 - 1 x 20

30 - no

40 - 2 x 20

50 - 1 x 50

60 - 3 x 20

70 - 1 x 50 + 1 x 20

80 - 4 x 20

90 - 1 x 50 + 2 x 20

100 - 2 x 50

110 - 1 x 50 + 3 x 20

120 - 2 x 50 + 1 x 20

130 - 1 x 50 + 4 x 20

140 - 2 x 50 + 2 x 20

...

### Q2 The number of 50s for the least total numbers of notes

The function should only return the number of 50s. But to know this, you must also know the number of 20s to fullfill the requirement of least total numbers of notes. Looking at the above table, you will see that there will be max. four 20 notes. So you need to write an algorithm to get the number of 20 and 50 notes for the input value:

- Check if value is a multiple of 50. If so number is value divided by 50
- Check if value minus 20 is a multiple of 50. If so number is value minus 20 divided by 50
- Check if value minus 40 is a multiple of 50. If so number is value minus 40 divided by 50
- Check if value minus 60 is a multiple of 50. If so number is value minus 60 divided by 50
- Check if value minus 80 is a multiple of 50. If so number is value minus 80 divided by 50
- Otherwise return zero (no 50 note)

canDispense will verify whether X can represented by only $20 and/or $50

dispense50s will search the total number of notes(least count) which is required to dispense the money.

as example

i) 160 is valid

need 5 notes (2x50, 3x20)

ii) 165 is invalid

it cannot be represented by only $50 and $20

If you have tried anything, you should share it with us

If you want to know if the number is valid, what would be your method?

If you want to calculate the note count, what would be your method?

Follow john arndit answer