📜  fibonacci sums ruby 代码示例

📅  最后修改于: 2022-03-11 15:04:45.840000             🧑  作者: Mango

代码示例1
# Write a method that finds the sum of the first n fibonacci numbers recursively. 
# Assume n > 0.

def fibs_sum(n)
  return 1 if n == 1
  return 2 if n == 2
  n + fibs_sum(n-1)
end