Error in calling a custom function from sage
I used this guide to add module containing some utility to the sage.
My module (myfunc.py
) looks like this:
def perm(n, r):
return factorial(n)/factorial(n-r)
def comb(n, r):
return perm(n, r)/factorial(r)
To import the module I use the following import
statement:
sage: from myfunc import perm
So far so good.
When I call the perm()
or comb()
function. I get the following error:
1 def perm(n, r):
----> 2 return factorial(n)/factorial(n-r)
3
4 def comb(n, r):
5 return perm(n, r)/factorial(r)
NameError: name 'factorial' is not defined