Linear Recurrences by Matrix Power

medium
Unit 20 · Data Structures0/3 to milestone

Computing the n-th Fibonacci number by iteration takes O(n) steps. With fast matrix exponentiation, it takes O(log n) matrix multiplications:

Pro problem

Unlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.

Start 7-day free trial
solution.py · Python 3.13
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Linear Recurrences by Matrix Power · TechGradify