Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 96c0eff

Browse files
committed
FEAT Implemented recursive factorial function
1 parent 550fee5 commit 96c0eff

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎main.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ def lg(n: float) -> int:
129129
# ---------------------------------------------------------------------------------------------------------
130130

131131

132+
def fact(n: int) -> int:
133+
if n == 1:
134+
return 1
135+
136+
return n * fact(n - 1)
137+
138+
139+
# ---------------------------------------------------------------------------------------------------------
140+
141+
132142
def main():
133143
"""Testing"""
134144
test_x: float = 0.1
@@ -191,6 +201,9 @@ def main():
191201
for i in range(40):
192202
print(Fibonacci.fib(i))
193203

204+
print()
205+
print(f"7!: { fact(7) }")
206+
194207

195208
# ---------------------------------------------------------------------------------------------------------
196209

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /