advanced
Algorithmic Complexity Reduction
Optimize a recursive function using advanced mathematical concepts.
📝 プロンプトの内容
Analyze a recursive function for calculating the nth Fibonacci number. Identify the performance bottlenecks, rewrite it using memoization to achieve O(n) time complexity, and further optimize it to O(log n) time complexity using matrix exponentiation. Explain the mathematical reasoning behind the final optimization.