Calculating Fibonacci Series using Dynamic Programming

Code in Python, courtesy of Google
(Note: 0 is not shown in the above image)
Image courtesy of Google

Fib(n) = Fib(n-1) + Fib(n-2) if n >= 2

Var0 = 0

Var1 = 1

Set Var0 to Var1 and Var1 to Var0 + Var1

Var0 = 1

Var1 = 1

F3 = Var1 = 1

Var0 = Var1 = 1

Var1 = Var1 + Var0 = 1 + 1 = 2

F4 = 2

(Note: Above code was implemented using Python and a semi-competent developer)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store