Understanding Recursion with Simple Examples?
java
dev.to
What is Recursion ? Recursion is when a function calls itself to solve a problem. Every recursion has 2 mandatory parts: Base Case (Stopping condition) If you don’t have this → your program will crash (infinite recursion) Recursive Call Function calls itself with a smaller/simpler input Examples: 1.1 2 3 4 5 flowchart: -In python : def display(num): if num > 5: return print(num) display(num + 1) display(1) output: -In Java : class