A fact(n) function that calls itself: fact(5) waits for fact(4), down to fact(1). Open Values and Step to watch the call stack.
RecursionAdvanced
Built from 6 kinds of block, between Start and End. Each one has a guide.
B4Coder writes the same program as real code. Change the flowchart in the editor and the code changes with it.
def fact(n): if n <= 1: return 1 else: smaller = fact(n - 1) return n * smaller
n = int(input("Factorial of which number? "))answer = fact(n)print(str(n) + "! = " + str(answer))How each block becomes code: Python · Java · C++ · C# · JavaScript