peter revised this gist 2 hours ago. Go to revision
1 file changed, 3 insertions, 2 deletions
public_test.md
| @@ -3,9 +3,10 @@ | |||
| 3 | 3 | This is a public gist on my self host gist site. | |
| 4 | 4 | ||
| 5 | 5 | ```python | |
| 6 | - | # Factorial Function | |
| 6 | + | # Factorial Function example | |
| 7 | + | ||
| 7 | 8 | def factorial(n: int) -> int: | |
| 8 | - | ''' Factorial, returns `n!`. Equal to `1*2*3*...n`. | |
| 9 | + | ''' Factorial, returns `n!`. Equal to `1*2*3*...n`. ''' | |
| 9 | 10 | if n < 0: | |
| 10 | 11 | raise ArgumentError("factorial invalid for negative values") | |
| 11 | 12 | if n <= 1: | |
peter revised this gist 2 hours ago. Go to revision
1 file changed, 1 insertion, 1 deletion
public_test.md
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | 3 | This is a public gist on my self host gist site. | |
| 4 | 4 | ||
| 5 | - | ```python\ | |
| 5 | + | ```python | |
| 6 | 6 | # Factorial Function | |
| 7 | 7 | def factorial(n: int) -> int: | |
| 8 | 8 | ''' Factorial, returns `n!`. Equal to `1*2*3*...n`. | |
peter revised this gist 2 hours ago. Go to revision
1 file changed, 16 insertions
public_test.md(file created)
| @@ -0,0 +1,16 @@ | |||
| 1 | + | # Public Gist | |
| 2 | + | ||
| 3 | + | This is a public gist on my self host gist site. | |
| 4 | + | ||
| 5 | + | ```python\ | |
| 6 | + | # Factorial Function | |
| 7 | + | def factorial(n: int) -> int: | |
| 8 | + | ''' Factorial, returns `n!`. Equal to `1*2*3*...n`. | |
| 9 | + | if n < 0: | |
| 10 | + | raise ArgumentError("factorial invalid for negative values") | |
| 11 | + | if n <= 1: | |
| 12 | + | return 1 | |
| 13 | + | return n * factorial(n - 1) | |
| 14 | + | ``` | |
| 15 | + | ||
| 16 | + | Over. | |