about | help | code help+videos | done | prefs |
tribonacci
Fibonacci sequence and Fibonacci numbers are extremely famous. The sequence begins with 0, 1 and each subsequent number is the sum of the two numbers before it. Thus fib(0) = 0, fib(1) = 1, fib(n) = fib(n-1) + fib(n-2). On the lines of Fibonacci numbers, we will define a Tribonacci sequence as one that starts with 0, 0, 1 and each subsequent number is the sum of the three numbers before it. Thus, tri(0) = 0, tri(1) = 0, tri(2) = 1, tri(n) = well, you know... Define a function that when passed an integer, returns the Tribonacci number at that index. Note: the difficulty is in solving this problem such that you DON'T call the function three times (during each call). tribonacci(0) → 0 tribonacci(10) → 81 tribonacci(20) → 35890 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 4 Post-solution available
Copyright Nick Parlante 2017 - privacy