I need to write a function to calculate the fictitious value of some selected items in a website.
- If The user Selects 1 item there is no discount and the value would be 1.
- If The user Selects 8 items there would be a little discount and the value would be 7.
- If The user Selects 24 items there would be a little discount and the value would be 20.
- If The user Selects 40 items there would be a little discount and the value would be 30.
- If The user Selects 80 items there would be a little discount and the value would be 50.
These are the only 4 discounts that will exist but they can be accumulative, so if the user selected 110 (80+24+6) the value should be (50+20+6). Let's see some other examples:
- If the user selects 5 items the value would be 5.
- If the user selects 12 items the value would be 7+4 = 11.
- If the user selects 23 items the value would be 7+7+7 = 21.
- If the user selects 24 items the value would be 20.
- If the user selects 77 items the value would be 30+20+7+5 = 62.
- If the user selects 88 items the value would be 50+7 = 57.
I hope I explained myself. I can guess I need to use mod logical operator but I have no idea on how to start writing this algorithm and I think I need a little help.