diff --git a/contributor_database b/contributor_database index 66bbf0288..67ac62ea8 100644 --- a/contributor_database +++ b/contributor_database @@ -27,4 +27,5 @@ bubble_sort: [Shobhit Sachan](@sachans) has_duplicates: [Rob-Rychs](@Rob-Rychs) keys_only: [Rob-Rychs](@Rob-Rychs) values_only: [Rob-Rychs](@Rob-Rychs) -all_unique: [Rob-Rychs](@Rob-Rychs) \ No newline at end of file +all_unique: [Rob-Rychs](@Rob-Rychs) +fibonnaci_until_num: [Nian Lee](@scraggard) diff --git a/snippets/fibonacci_until_num.md b/snippets/fibonacci_until_num.md new file mode 100644 index 000000000..12dc2fc04 --- /dev/null +++ b/snippets/fibonacci_until_num.md @@ -0,0 +1,18 @@ +### fibonacci_until_num + +Returns the n-th term in a Fibonnaci sequence that starts with 1 + +A term in a Fibonnaci sequence is the sum of the two previous terms. +This function recursively calls the function to find the n-th term. + +``` python +def fibonacci_until_num(n): + if n < 3: + return 1 + return fibonacci_until_num(n - 2) + fibonacci_until_num(n - 1) +``` + +``` python +fibonnaci_until_num(5) # 5 +fibonnaci_until_num(15) # 610 +```