D.5 递归

Using recursion for adaptive integration

demo(recursion)

斐波那契数列

# 递归 Recall
fibonacci <- function(n) {
  if (n <= 2) {
    if (n >= 0) 1 else 0
  } else {
    Recall(n - 1) + Recall(n - 2)
  }
}
fibonacci(10) # 55
## [1] 55