changed fib function to be nicer with negative input
This commit is contained in:
parent
914a9632a0
commit
4e3716f749
@ -12,12 +12,10 @@ channel.queue_declare(queue='rpc_queue')
|
||||
|
||||
|
||||
def fib(n):
|
||||
if n == 0:
|
||||
return 0
|
||||
elif n == 1:
|
||||
return 1
|
||||
else:
|
||||
if n > 1:
|
||||
return fib(n-1) + fib(n-2)
|
||||
else:
|
||||
return n
|
||||
|
||||
def on_request(ch, method, props, body):
|
||||
n = int(body)
|
||||
|
Loading…
Reference in New Issue
Block a user