Guest User

Untitled

a guest
Jul 20th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. package twelvedays
  2.  
  3. import scala.annotation.tailrec
  4. class TwelveDays {
  5.  
  6. @tailrec
  7. final def calculateGiftsGivenOnDay(day: Int, totalGifts: Int = 0): Int = {
  8. if (day == 1) {
  9. totalGifts + day
  10. } else {
  11. calculateGiftsGivenOnDay(day - 1, totalGifts + day)
  12. }
  13. }
  14.  
  15. }
Add Comment
Please, Sign In to add comment