Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

fibonacci sums ruby

# 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
Comment

PREVIOUS NEXT
Code Example
Ruby :: ruby array includes 
Ruby :: simple form for rails dates 
Ruby :: how to add uniqueness in rails migration 
Ruby :: ruby get file folder 
Ruby :: find path of module in ruby 
Ruby :: ruby file get line number 
Ruby :: run a specific migration rails 
Ruby :: ruby regexp match all 
Ruby :: rails check_box_tag 
Ruby :: ruby symbolize_keys 
Ruby :: how to get new line to display in rails 
Ruby :: ruby substring remove 
Ruby :: ruby match word in string 
Ruby :: generate csv ruby 
Ruby :: singleton class in ruby 
Ruby :: ruby group by 
Ruby :: rails setup test db 
Ruby :: timeout in rails 
Ruby :: ruby delete first element of array 
Ruby :: ruby array of symbols shorthand 
Ruby :: rails server not updating 
Ruby :: call the api from ruby 
Ruby :: infinite loop in ruby 
Ruby :: check if the substring is present in the column of the record rails console 
Ruby :: ruby do something x times 
Ruby :: how to create tenant again using Appartment in rails 
Ruby :: rotate array by k times in rails 
Ruby :: difference between is_a and kind_of ruby 
Ruby :: elsif ruby 
Ruby :: ruby on rails project 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =