This is it:
def _eval(self, n):
"""
EXAMPLES::
sage: [sloane.A000142._eval(n) for n in range(10)]
[1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880]
"""
return arith.factorial(n)
> I only see
> the stuff that shows up when i do sloane.A000142(<tab>
> Can you make this code to print "hello world" when the sequence is called in
> sage as an example?
Put
print "hello world"
right before
return arith.factorial(n) in the code above.
> Also, I'm going to implement a sequence that uses factorials, and I remember
> that I'm supposed to load something up before I use it... what is it?
You can just use arith.factorial(n), like is done in the above
example. You can use
anything from Sage by doing
from sage.all import name_of_function
in the body of your function.
William
> Thank you,
> Daniel
>
>
>
> class A000142(SloaneSequence):
> def __init__(self):
> r"""
> Factorial numbers: `n! = 1 \cdot 2 \cdot 3 \cdots n`
>
> Order of symmetric group `S_n`, number of permutations of
> `n` letters.
>
> INPUT:
>
>
> - ``n`` - non negative integer
>
>
> OUTPUT:
>
>
> - ``integer`` - function value
>
>
> EXAMPLES::
>
> sage: a = sloane.A000142;a
> Factorial numbers: n! = 1*2*3*4*...*n (order of symmetric group
> S_n, $
> sage: a(0)
> 1
> sage: a(8)
> 40320
> sage: a(40)
> 815915283247897734345611269596115894272000000000
> sage: a.list(9)
> [1, 1, 2, 6, 24, 120, 720, 5040, 40320]
>
> AUTHORS:
>
> - Jaap Spies (2007-01-12)
> """
> SloaneSequence.__init__(self, offset=0)
>
> def _repr_(self):
> """
> EXAMPLES::
>
> sage: sloane.A000142._repr_()
> 'Factorial numbers: n! = 1*2*3*4*...*n (order of symmetric group
> S_n,$
> """
> return "Factorial numbers: n! = 1*2*3*4*...*n (order of symmetric
> group S$
>
> def _eval(self, n):
> """
> EXAMPLES::
> sage: a(8)
> 40320
> sage: a(40)
> 815915283247897734345611269596115894272000000000
> sage: a.list(9)
> [1, 1, 2, 6, 24, 120, 720, 5040, 40320]
>
> AUTHORS:
>
> - Jaap Spies (2007-01-12)
> """
> SloaneSequence.__init__(self, offset=0)
>
> def _repr_(self):
> """
> EXAMPLES::
>
> sage: sloane.A000142._repr_()
> 'Factorial numbers: n! = 1*2*3*4*...*n (order of symmetric group
> S_n,$
> """
> return "Factorial numbers: n! = 1*2*3*4*...*n (order of symmetric
> group S$
>
> def _eval(self, n):
> """
> EXAMPLES::
>
> sage: [sloane.A000142._eval(n) for n in range(10)]
> [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880]
> """
> return arith.factorial(n)
>
>
>
>
>
--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org