Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Martin Mareš
prm2
Commits
1989b6bb
Commit
1989b6bb
authored
Apr 29, 2021
by
Martin Mareš
Browse files
Rekurze: Ještě Fibonacci v konstantní paměti
parent
64f1e21f
Changes
1
Hide whitespace changes
Inline
Side-by-side
07-rekurze/fib.py
View file @
1989b6bb
...
...
@@ -26,3 +26,13 @@ def fib2(n):
for
i
in
range
(
2
,
n
+
1
):
p
[
i
]
=
p
[
i
-
1
]
+
p
[
i
-
2
]
return
p
[
n
]
### Iterativní řešení s konstantní pamětí
def
fib3
(
n
):
if
n
<
2
:
return
n
a
,
b
=
0
,
1
for
i
in
range
(
1
,
n
):
a
,
b
=
b
,
a
+
b
return
b
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment