Sign in
go
/
website
/
e7879e0f78ec3dbf8b9f42f3381d2a34a77fb423
/
.
/
_content
/
talks
/
2013
/
go4python
/
fib.py
blob: afc57fa15d5ce761a8c53f7e59d7afdf9eb1f9b7 [
file
] [
log
] [
blame
]
#!/usr/bin/python
def
fib
(
n
):
a
,
b
=
0
,
1
for
i
in
range
(
n
):
a
,
b
=
b
,
a
+
b
return
b
def
fib_rec
(
n
):
if
n
<=
1
:
return
1
else
:
return
fib_rec
(
n
-
1
)
+
fib_rec
(
n
-
2
)
for
x
in
range
(
10
):
print
fib
(
x
),
fib_rec
(
x
)