79362348

Date: 2025-01-16 16:25:54
Score: 1
Natty:
Report link

Instead of printing, consider using module memory_graph to graph the recursion. A simple example for a factorial() function looks like:

import memory_graph # see link above for install instructions

def factorial(n):
    if n==0:
        return 1
    memory_graph.show( memory_graph.get_call_stack(), block=True )
    result = n * factorial(n-1)
    memory_graph.show( memory_graph.get_call_stack(), block=True )
    return result

print(factorial(3)) # 6

factorial graphed

Full disclosure: I am the developer of memory_graph.

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: bterwijn