master-algorithms-py/math_logic_dp
2023-07-29 21:03:50 -07:00
..
climbing_stairs.py dp 2023-07-29 11:13:47 -07:00
fibonacci.py Rename fibonacci.py to fibonacci.py 2023-07-29 11:12:39 -07:00
playing_with_math.py Rename playing_with_math.py to playing_with_math.py 2023-07-29 11:12:51 -07:00
README.md Update README.md 2023-07-29 21:03:50 -07:00

math, logic, dynamic programming


dynamic programming


  • take a recursive algorithm and cache overlapping problems (repeated calls).
  • the runtime is given by the number of calls.
  • top-down: how can we divide the problem into sub-problems?
    • top-down dynamic programming is called memoization.
  • bottom-up: solve for a simple case, then figure out for more elements.


examples


python3 fibonacci.py

Testing fibonacci
Fibonacci of 10: 55

python playing_with_math.py

Greatest common divider of 21 and 7 is 7
Prime factors of 21 are [3, 7]