Number of Apples Left

Published by Mubashir Hassan in

A man has n number of apples. If he eats a percentage p of the apples (if apples are available), his children will share the remainder of the apples. Create a function to determine the number of whole apples his children got. If his children did not get any apples, return -1.

Examples

getNumberOfApples(10, "90%") ➞ 1

getNumberOfApples(25, "10%") ➞ 22

getNumberOfApples(0, "10%") ➞ -1

Notes

p will always be given.

Watch a quick demo on how Edabit works.