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
|
||||
|
||||
```python
|
||||
def fibo(n: int) -> int:
|
||||
a = 0
|
||||
b = 1
|
||||
c = 0
|
||||
i = 2
|
||||
while i <= n:
|
||||
c = a + b
|
||||
a = b
|
||||
b = c
|
||||
i += 1
|
||||
return b
|
||||
def fibo(n):
|
||||
prev = 1 #f0
|
||||
cur = 1 #f1
|
||||
while n> 1:
|
||||
(prev, cur) = (cur, prev+cur)
|
||||
n -= 1
|
||||
return cur
|
||||
# OR
|
||||
|
||||
```
|
||||
|
||||
## Exercise 1.5
|
||||
|
Loading…
x
Reference in New Issue
Block a user