about | help | code help+videos | done | prefs |
apcsaLoopsWhichFib
Given an input num, return which number in the Fibonacci sequence is equal to or greater than num. The Fibonacci sequence is f(0) = 0, f(1) = 1, f(n) = f(n - 1) + f(n - 2). Computing Fibonacci is quite simple using a while loop and a few variables; the only additional chore here is figuring out when to stop based not on how many numbers to print (which is the usual Fibonacci programming problem), but when you have reached a certain value. Precondition: num > 3. HINT: update the variables in a sequence. Also, what kind of loop do you need when you don't know how many Fibonacci numbers to go through?apcsaLoopsWhichFib(4) → 5 apcsaLoopsWhichFib(5) → 5 apcsaLoopsWhichFib(6) → 6 ...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: 210
Copyright Nick Parlante 2017 - privacy