Commit c5dfd645 authored by Tom Niget's avatar Tom Niget

Add fibonacci fork+sequential tests

parent f5e72370
from typon import fork, sync
def fibo(n):
def fibo(n: int) -> int:
if n < 2:
return n
a = fibo(n - 1)
b = fibo(n - 2)
a = fork(lambda: fibo(n - 1))
b = fork(lambda: fibo(n - 2))
sync()
return a + b
#def fibo(n: int) -> int:
# if n < 2:
# return n
# a = fork(lambda: fibo(n - 1))
# b = fork(lambda: fibo(n - 2))
# sync()
# return a + b
if __name__ == "__main__":
print(fibo(30)) # should display 832040
\ No newline at end of file
def fibo(n):
if n < 2:
return n
a = fibo(n - 1)
b = fibo(n - 2)
return a + b
if __name__ == "__main__":
print(fibo(30)) # should display 832040
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment