Want to learn machine learning? Use my machine learning flashcards.

# Recursive Functions

## Simple factorial

`print(5*4*3*2*1)`

```
120
```

## Recursive function

The tell-tale sign of a recursive function is a function that calls itself

```
# Create a function inputing n, that,
def factorial(n):
# if n is less than or equal to 1,
if n <= 1:
# return n,
return n
# if not, return n multiplied by the output
# of the factorial function of one less than n
return n*factorial(n-1)
# run the function
factorial(5)
```

```
120
```