The most common sample of recursion is always doing factorials, of course. So here it is in Python.
def main(): num = int(input("Please enter a non-negative integer.\n")) fact = factorial(num) print("The factorial of", num, "is", fact) def factorial(num): if num == 0: return 1 else: return num * factorial(num - 1) main()