# Question:

You have 15 Rs with you. You go to a shop and shopkeeper tells you price as 1 Rs per chocolate. He also tells you that you can get a chocolate in return of 3 wrappers. How many maximum chocolates you can eat?

# Solution:

`Answer: 22Buy and eat 15 chocolatesReturn 15 wrappers and get 5 more chocolates.Return 3 wrappers, get 1 chocolate and eat it (keep 2 wrappers)Now we have 3 wrappers. Return 3 and get 1 more chocolate.So total chocolates = 15 + 5 + 1 + 1An efficient solution is to use a direct formula to find the number of chocolates.Find initial number of chocolates bydividing the amount with per piece cost.i.e. choc = money / pricethen apply below formulachoc += (choc - 1)/(wrap - 1)`

# Code:

Placewit grows the best engineers by providing an interactive classroom experience and by helping them develop their skills and get placed in amazing companies.

--

--

--

## More from Placewit

Upskilling students for tech placements!

Love podcasts or audiobooks? Learn on the go with our new app.

## Placewit

Upskilling students for tech placements!