- #1
Whovian
- 652
- 3
I tried the following code:
Basically, for all n and r from 1 to 100, it's supposed to print ##\binom{n}{r}##
Unfortunately, running from the command line, I get:
Code:
def factorial(n):
if (n == 0):
return 1
else:
return n*factorial(n-1)
def ncr(n,r):
return ((factorial(n))/(factorial(r)*factorial(n-r)))
number = 0
for n in range(100):
for r in range(100):
print ncr(n,r)
Basically, for all n and r from 1 to 100, it's supposed to print ##\binom{n}{r}##
Unfortunately, running from the command line, I get:
Code:
Traceback (most recent call last):
File "Pythontest.py", line 14, in <module>
print ncr(n,r)
File "Pythontest.py", line 8, in ncr
return ((factorial(n))/(factorial(r)*factorial(n-r)))
File "Pythontest.py", line 5, in factorial
return n*factorial(n-1)
File "Pythontest.py", line 5, in factorial
return n*factorial(n-1)
File "Pythontest.py", line 5, in factorial
return n*factorial(n-1)