8000 changed fib function to be nicer with negative input · syk-coder/rabbitmq-tutorials@a3e8c85 · GitHub
[go: up one dir, main page]

Skip to content

Commit a3e8c85

Browse files
author
Ann Witbrock
committed
changed fib function to be nicer with negative input
1 parent 9fc4bc9 commit a3e8c85

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

python/rpc_server.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212

1313

1414
def fib(n):
15-
if n == 0:
16-
return 0
17-
elif n == 1:
18-
return 1
19-
else:
15+
if n > 1:
2016
return fib(n-1) + fib(n-2)
17+
else:
18+
return n
2119

2220
def on_request(ch, method, props, body):
2321
n = int(body)

0 commit comments

Comments
 (0)
0