Python#
Block Highlighting#
Language highlighting can be enabled with Highlight.js by adding a supported programming language name directly after the first ```
grouping in a Markdown code block:
# calculate factorial of n
def fact(n):
# no work required
if n == 1 or n == 0:
return 1
# minimum amount of work
return n * fact(n - 1)
if __name__=="__main__":
n = 5
factorial = fact(n)
print(f"{n}! = {factorial}")
Block Markdown#
```python
# calculate factorial of n
def fact(n):
# no work required
if n == 1 or n == 0:
return 1
# minimum amount of work
return n * fact(n - 1)
if __name__=="__main__":
n = 5
factorial = fact(n)
print(f"{n}! = {factorial}")
```
Script adapted from Palistha Singh's "How Does Recursion Work? Explained with Code Examples"