fork(1) download
  1. object Main extends App {
  2.  
  3. def countChange(money: Int, coins: List[Int]): Int =
  4. if (money < 0)
  5. 0
  6. else if (coins.isEmpty)
  7. if (money == 0) 1
  8. else 0
  9. countChange(money - coins.head, coins) +
  10. countChange(money, coins.tail)
  11.  
  12.  
  13. println(countChange(20, List(1, 2, 5, 10)))
  14.  
  15. }
Success #stdin #stdout 0.39s 381952KB
stdin
Standard input is empty
stdout
40