Fibonacci
Track only the previous two numbers and iterate until you reach n. This keeps the solution clear and avoids exponential recursion.
Return the nth Fibonacci number.
Tagged with math
Track only the previous two numbers and iterate until you reach n. This keeps the solution clear and avoids exponential recursion.
Return the nth Fibonacci number.
Compute the expected sum from 0 through n and subtract the actual sum of the list to find the missing number.
Given numbers from 0 to n with one missing, return the missing value.