Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def howManyGames(p, d, m, s)
- price = p
- discount = d
- money = s
- games = 0
- while money >= price
- money = money - price # paid one game
- games = games + 1 # got one game
- price = price - discount # price is reduced by promotion
- price = price > m ? price : m # until it reaches a bottom limit
- end
- return games
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement