vault backup: 2023-11-24 14:33:51
This commit is contained in:
parent
fd79eb30a2
commit
601e9f0dd6
@ -76,17 +76,15 @@ def power(x, n):
|
|||||||
## Exercise 1.4
|
## Exercise 1.4
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def fibo(n: int) -> int:
|
def fibo(n):
|
||||||
a = 0
|
prev = 1 #f0
|
||||||
b = 1
|
cur = 1 #f1
|
||||||
c = 0
|
while n> 1:
|
||||||
i = 2
|
(prev, cur) = (cur, prev+cur)
|
||||||
while i <= n:
|
n -= 1
|
||||||
c = a + b
|
return cur
|
||||||
a = b
|
# OR
|
||||||
b = c
|
|
||||||
i += 1
|
|
||||||
return b
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Exercise 1.5
|
## Exercise 1.5
|
||||||
|
Loading…
x
Reference in New Issue
Block a user