Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package twelvedays
- import scala.annotation.tailrec
- class TwelveDays {
- @tailrec
- final def calculateGiftsGivenOnDay(day: Int, totalGifts: Int = 0): Int = {
- if (day == 1) {
- totalGifts + day
- } else {
- calculateGiftsGivenOnDay(day - 1, totalGifts + day)
- }
- }
- }
Add Comment
Please, Sign In to add comment