diveintopython
diveintopython copied to clipboard
Naming Confusion in Chapter 2.5 "Indenting Code" > Example 2.6 "if statements
The issue is not in logic but in naming. I know that the function could be named anything. However, it is confusing because the function is called "fib" when it is actually performing factorial.
On this page: http://www.diveintopython.net/getting_to_know_python/indenting_code.html
Code:
def fib(n):
print 'n =', n
if n > 1:
return n * fib(n - 1)
else:
print 'end of the line'
return 1