18.2 Functions that compute some of the sequences in Sloane's tables

Module: sage.combinat.sloane_functions

Functions that compute some of the sequences in Sloane's tables

Type sloane.[tab] to see a list of the sequences that are defined.

sage: a = sloane.A000005; a
 The integer sequence tau(n), which is the number of divisors of n.
 sage: a(1)
 1
 sage: a(6)
 4
 sage: a(100)
 9

Type d._eval?? to see how the function that computes an individual term of the sequence is implemented.

The input must be a positive integer:

sage: a(0)
Traceback (most recent call last):
...
ValueError: input n (=0) must be a positive integer
sage: a(1/3)
Traceback (most recent call last):
...
TypeError: input must be an int, long, or Integer

You can also change how a sequence prints:

sage: a = sloane.A000005; a
The integer sequence tau(n), which is the number of divisors of n.
sage: a.rename('(..., tau(n), ...)')
sage: a
(..., tau(n), ...)
sage: a.reset_name()
sage: a
The integer sequence tau(n), which is the number of divisors of n.

TESTS:

sage: a = sloane.A000001;
sage: a == loads(dumps(a))
True

Author Log:

Module-level Functions

perm_mh( m, h)

This functions calculates $ f(g,h)$ from Sloane's sequences A079908-A079928

Input:

m
- positive integer
h
- non negative integer

Output: permanent of the m x (m+h) matrix, etc.

sage: from sage.combinat.sloane_functions import perm_mh
sage: perm_mh(3,3)
36
sage: perm_mh(3,4)
76

Author: Jaap Spies (2006)

recur_gen2( a0, a1, a2, a3)

homogenous general second-order linear recurrence generator with fixed coefficients

a(0) = a0, a(1) = a1, a(n) = a2*a(n-1) + a3*a(n-2)

sage: from sage.combinat.sloane_functions import recur_gen2
sage: it = recur_gen2(1,1,1,1)
sage: [it.next() for i in range(10)]
[1, 1, 2, 3, 5, 8, 13, 21, 34, 55]

recur_gen2b( a0, a1, a2, a3, b)

inhomogenous second-order linear recurrence generator with fixed coefficients and $ b = f(n)$

$ a(0) = a0$ , $ a(1) = a1$ , $ a(n) = a2*a(n-1) + a3*a(n-2) +f(n)$ .

sage: from sage.combinat.sloane_functions import recur_gen2b
sage: it = recur_gen2b(1,1,1,1, lambda n: 0)
sage: [it.next() for i in range(10)]
[1, 1, 2, 3, 5, 8, 13, 21, 34, 55]

recur_gen3( a0, a1, a2, a3, a4, a5)

homogenous general third-order linear recurrence generator with fixed coefficients

a(0) = a0, a(1) = a1, a(2) = a2, a(n) = a3*a(n-1) + a4*a(n-2) + a5*a(n-3)

sage: from sage.combinat.sloane_functions import recur_gen3
sage: it = recur_gen3(1,1,1,1,1,1)
sage: [it.next() for i in range(10)]
[1, 1, 1, 3, 5, 9, 17, 31, 57, 105]

Class: A000001

class A000001
A000001( self)

Number of groups of order $ n$ .

Note: The database_gap-4.4.9 must be installed for $ n > 50$ .

run sage -i database_gap-4.4.9 or higher first.

Input:

n
- positive integer

Output: integer

sage: a = sloane.A000001;a
Number of groups of order n.
sage: a(0)
Traceback (most recent call last):
...
ValueError: input n (=0) must be a positive integer
sage: a(1) #optional database_gap
1
sage: a(2) #optional database_gap
1
sage: a(9) #optional database_gap
2
sage: a.list(16) #optional database_gap
[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14]
sage: a(60)     # optional
13

Author: Jaap Spies (2007-02-04)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: sloane.A000001._eval(4)
2
sage: sloane.A000001._eval(51) #optional requires database_gap

_repr_( self)

sage: sloane.A000001._repr_()
'Number of groups of order n.'

Class: A000004

class A000004
A000004( self)

The zero sequence.

Input:

n
- non negative integer

Output:

sage: a = sloane.A000004; a
The zero sequence.
sage: a(1)
0
sage: a(2007)
0
sage: a.list(12)
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Author: Jaap Spies (2006-12-10)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: sloane.A000004._eval(5)
0

_repr_( self)

sage: sloane.A000004._repr_()
'The zero sequence.'

Class: A000005

class A000005
A000005( self)

The sequence $ tau(n)$ , which is the number of divisors of $ n$ .

This sequence is also denoted $ d(n)$ (also called $ tau(n)$ or $ \sigma_0(n)$ ), the number of divisors of n.

Input:

n
- positive integer

Output:

sage: d = sloane.A000005; d
The integer sequence tau(n), which is the number of divisors of n.
sage: d(1)
1
sage: d(6)
4
sage: d(51)
4
sage: d(100)
9
sage: d(0)
Traceback (most recent call last):
...
ValueError: input n (=0) must be a positive integer
sage: d.list(10)
[1, 2, 2, 3, 2, 4, 2, 4, 3, 4]

Author Log:

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: sloane.A000005._eval(5)
2

_repr_( self)

sage: sloane.A000005._repr_()
'The integer sequence tau(n), which is the number of divisors of n.'

Class: A000007

class A000007
A000007( self)

The characteristic function of 0: $ a(n) = 0^n$ .

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000007;a
The characteristic function of 0: a(n) = 0^n.
sage: a(0)
1
sage: a(2)
0
sage: a(12)
0
sage: a.list(12)
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Author: Jaap Spies (2007-01-12)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000007._eval(n) for n in range(10)]
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0]

_repr_( self)

sage: sloane.A000007._repr_()
'The characteristic function of 0: a(n) = 0^n.'

Class: A000009

class A000009
A000009( self)

Number of partitions of $ n$ into odd parts.

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000009;a
Number of partitions of n into odd parts.
sage: a(0)
1
sage: a(1)
1
sage: a(13)
18
sage: a.list(14)
[1, 1, 1, 2, 2, 3, 4, 5, 6, 8, 10, 12, 15, 18]

Author: Jaap Spies (2007-01-30)

Functions: cf,$ \,$ list

cf( self)

sage: it = sloane.A000009.cf()
sage: [it.next() for i in range(14)]
[1, 1, 1, 2, 2, 3, 4, 5, 6, 8, 10, 12, 15, 18]

list( self, n)

sage: sloane.A000009.list(14)
[1, 1, 1, 2, 2, 3, 4, 5, 6, 8, 10, 12, 15, 18]

Special Functions: __init__,$ \,$ _eval,$ \,$ _precompute,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000009._eval(i) for i in range(14)]
[1, 1, 1, 2, 2, 3, 4, 5, 6, 8, 10, 12, 15, 18]

_precompute( self, [how_many=50])

sage: initial = len(sloane.A000009._b)
sage: sloane.A000009._precompute(10)
sage: len(sloane.A000009._b) - initial == 10
True

_repr_( self)

sage: sloane.A000009._repr_()
'Number of partitions of n into odd parts.'

Class: A000010

class A000010
A000010( self)

The integer sequence A000010 is Euler's totient function.

Number of positive integers $ i < n$ that are relative prime to $ n$ . Number of totatives of $ n$ .

Euler totient function $ \phi(n)$ : count numbers < $ n$ and prime to $ n$ . euler_phi is a standard SAGE function implemented in PARI

Input:

n
- positive integer

Output:
integer
- function value

sage: a = sloane.A000010; a
Euler's totient function
sage: a(1)
1
sage: a(0)
Traceback (most recent call last):
...
ValueError: input n (=0) must be a positive integer
sage: a(11)
10
sage: a.list(12)
[1, 1, 2, 2, 4, 2, 6, 4, 6, 4, 10, 4]
sage: a(1/3)
Traceback (most recent call last):
...
TypeError: input must be an int, long, or Integer

Author: Jaap Spies (2007-01-12)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000010._eval(n) for n in range(1,11)]
       [1, 1, 2, 2, 4, 2, 6, 4, 6, 4]

_repr_( self)

sage: sloane.A000010._repr_()
"Euler's totient function"

Class: A000012

class A000012
A000012( self)

The all 1's sequence.

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000012; a
The all 1's sequence.
sage: a(1)
1
sage: a(2007)
1
sage: a.list(12)
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

Author: Jaap Spies (2007-01-12)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000012._eval(n) for n in range(10)]
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

_repr_( self)

sage: sloane.A000012._repr_()
"The all 1's sequence."

Class: A000015

class A000015
A000015( self)

Smallest prime power $ \geq n$ .

Input:

n
- positive integer

Output:
integer
- function value

sage: a = sloane.A000015; a
Smallest prime power >= n.
sage: a(1)
1
sage: a(8)
8
sage: a(305)
307
sage: a(-4)
Traceback (most recent call last):
...
ValueError: input n (=-4) must be a positive integer
sage: a.list(12)
[1, 2, 3, 4, 5, 7, 7, 8, 9, 11, 11, 13]
sage: a(0)
Traceback (most recent call last):
...
ValueError: input n (=0) must be a positive integer

Author: Jaap Spies (2007-01-18)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000015._eval(n) for n in range(1,11)]
       [1, 2, 3, 4, 5, 7, 7, 8, 9, 11]

_repr_( self)

sage: sloane.A000015._repr_()
'Smallest prime power >= n.'

Class: A000016

class A000016
A000016( self)

Sloane's A000016

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000016; a
Sloane's A000016.
sage: a(1)
1
sage: a(0)
1
sage: a(8)
16
sage: a(75)
251859545753048193000
sage: a(-4)
Traceback (most recent call last):
...
ValueError: input n (=-4) must be an integer >= 0
sage: a.list(12)
[1, 1, 1, 2, 2, 4, 6, 10, 16, 30, 52, 94]

Author: Jaap Spies (2007-01-18)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000016._eval(n) for n in range(10)]
       [1, 1, 1, 2, 2, 4, 6, 10, 16, 30]

_repr_( self)

sage: sloane.A000016._repr_()
"Sloane's A000016."

Class: A000027

class A000027
A000027( self)

The natural numbers. Also called the whole numbers, the counting numbers or the positive integers.

The following examples are tests of SloaneSequence more than A000027.

sage: s = sloane.A000027; s
The natural numbers.
sage: s(10)
10

Index n is interpreted as _eval(n):

sage: s[10]
10

Slices are interpreted with absolute offsets, so the following returns the terms of the sequence up to but not including the third term:

sage: s[:3]
[1, 2]
sage: s[3:6]
[3, 4, 5]
sage: s.list(5)
[1, 2, 3, 4, 5]

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: sloane.A000027._eval(5)
5

_repr_( self)

sage: sloane.A000027._repr_()
'The natural numbers.'

Class: A000030

class A000030
A000030( self)

Initial digit of $ n$ .

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000030; a
Initial digit of n
sage: a(0)
0
sage: a(1)
1
sage: a(8)
8
sage: a(454)
4
sage: a(-4)
Traceback (most recent call last):
...
ValueError: input n (=-4) must be an integer >= 0
sage: a.list(12)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1]

Author: Jaap Spies (2007-01-18)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000030._eval(n) for n in range(10)]
       [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

_repr_( self)

sage: sloane.A000030._repr_()
'Initial digit of n'

Class: A000032

class A000032
A000032( self)

Lucas numbers (beginning at 2): $ L(n) = L(n-1) + L(n-2)$ .

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000032; a
Lucas numbers (beginning at 2): L(n) = L(n-1) + L(n-2).
sage: a(0)
2
sage: a(1)
1
sage: a(8)
47
sage: a(200)
627376215338105766356982006981782561278127
sage: a(-4)
Traceback (most recent call last):
...
ValueError: input n (=-4) must be an integer >= 0
sage: a.list(12)
[2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199]

Author: Jaap Spies (2007-01-18)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000032._eval(n) for n in range(10)]
       [2, 1, 3, 4, 7, 11, 18, 29, 47, 76]

_repr_( self)

sage: sloane.A000032._repr_()
'Lucas numbers (beginning at 2): L(n) = L(n-1) + L(n-2).'

Class: A000035

class A000035
A000035( self)

A simple periodic sequence.

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000035;a
A simple periodic sequence.
sage: a(0.0)
Traceback (most recent call last):
...
TypeError: input must be an int, long, or Integer
sage: a(1)
1
sage: a(2)
0
sage: a(9)
1
sage: a.list(10)
[0, 1, 0, 1, 0, 1, 0, 1, 0, 1]

Author: Jaap Spies (2007-02-02)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000035._eval(n) for n in range(10)]
       [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]

_repr_( self)

sage: sloane.A000035._repr_()
'A simple periodic sequence.'

Class: A000040

class A000040
A000040( self)

The prime numbers.

Input:

n
- positive integer

Output:
integer
- function value

sage: a = sloane.A000040; a
The prime numbers.
sage: a(1)
2
sage: a(8)
19
sage: a(305)
2011
sage: a.list(12)
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
sage: a(0)
Traceback (most recent call last):
...
ValueError: input n (=0) must be a positive integer

Author: Jaap Spies (2007-01-17)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000040._eval(n) for n in range(1,11)]
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]

_repr_( self)

sage: sloane.A000040._repr_()
'The prime numbers.'

Class: A000041

class A000041
A000041( self)

$ a(n)$ = number of partitions of $ n$ (the partition numbers).

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000041;a
a(n) = number of partitions of n (the partition numbers).
sage: a(0)
1
sage: a(2)
2
sage: a(8)
22
sage: a(200)
3972999029388
sage: a.list(9)
[1, 1, 2, 3, 5, 7, 11, 15, 22]

Author: Jaap Spies (2007-01-18)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000041._eval(n) for n in range(1,11)]
       [1, 2, 3, 5, 7, 11, 15, 22, 30, 42]

_repr_( self)

sage: sloane.A000041._repr_()
'a(n) = number of partitions of n (the partition numbers).'

Class: A000043

class A000043
A000043( self)

Primes $ p$ such that $ 2^p - 1$ is prime. $ 2^p - 1$ is then called a Mersenne prime.

Input:

n
- positive integer

Output:
integer
- function value

sage: a = sloane.A000043;a
Primes p such that 2^p - 1 is prime. 2^p - 1 is then called a Mersenne
prime.
sage: a(1)
2
sage: a(2)
3
sage: a(39)
13466917
sage: a(40)
Traceback (most recent call last):
...
IndexError: list index out of range
sage: a.list(12)
[2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127]

Author: Jaap Spies (2007-01-26)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000043._eval(n) for n in range(1,11)]
       [2, 3, 5, 7, 13, 17, 19, 31, 61, 89]

_repr_( self)

sage: sloane.A000043._repr_()
'Primes p such that 2^p - 1 is prime. 2^p - 1 is then called a Mersenne
prime.'

Class: A000045

class A000045
A000045( self)

Sequence of Fibonacci numbers, offset 0,4.

REFERENCES: S. Plouffe, Project Gutenberg, The First 1001 Fibonacci Numbers, http://ibiblio.org/pub/docs/books/gutenberg/etext01/fbncc10.txt We have one more. Our first Fibonacci number is 0.

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000045; a
Fibonacci numbers with index n >= 0
sage: a(0)
0
sage: a(1)
1
sage: a.list(12)
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
sage: a(1/3)
Traceback (most recent call last):
...
TypeError: input must be an int, long, or Integer

Author: Jaap Spies (2007-01-13)

Functions: fib,$ \,$ list

fib( self)

Returns a generator over all Fibanacci numbers, starting with 0.

sage: it = sloane.A000045.fib()
       sage: [it.next() for i in range(10)]
       [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]

list( self, n)

sage: sloane.A000045.list(10)
       [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]

Special Functions: __init__,$ \,$ _eval,$ \,$ _precompute,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000045._eval(n) for n in range(1,11)]
       [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]

_precompute( self, [how_many=500])

sage: initial = len(sloane.A000045._b)
sage: sloane.A000045._precompute(10)
sage: len(sloane.A000045._b) - initial > 0
True

_repr_( self)

sage: sloane.A000045._repr_()
'Fibonacci numbers with index n >= 0'

Class: A000069

class A000069
A000069( self)

Odious numbers: odd number of 1's in binary expansion.

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000069; a
Odious numbers: odd number of 1's in binary expansion.
sage: a(0)
1
sage: a(2)
4
sage: a.list(9)
[1, 2, 4, 7, 8, 11, 13, 14, 16]

Author: Jaap Spies (2007-02-02)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000069._eval(n) for n in range(10)]
       [1, 2, 4, 7, 8, 11, 13, 14, 16, 19]

_repr_( self)

sage: sloane.A000069._repr_()
"Odious numbers: odd number of 1's in binary expansion."

Class: A000073

class A000073
A000073( self)

Tribonacci numbers: a(n) = a(n-1) + a(n-2) + a(n-3). Starting with 0, 0, 1, ...

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000073;a
Tribonacci numbers: a(n) = a(n-1) + a(n-2) + a(n-3).
sage: a(0)
0
sage: a(1)
0
sage: a(2)
1
sage: a(11)
149
sage: a.list(12)
[0, 0, 1, 1, 2, 4, 7, 13, 24, 44, 81, 149]

Author: Jaap Spies (2007-01-19)

Functions: list

list( self, n)

sage: sloane.A000073.list(10)
[0, 0, 1, 1, 2, 4, 7, 13, 24, 44]

Special Functions: __init__,$ \,$ _eval,$ \,$ _precompute,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000073._eval(n) for n in range(10)]
[0, 0, 1, 1, 2, 4, 7, 13, 24, 44]

_precompute( self, [how_many=20])

sage: initial = len(sloane.A000073._b)
sage: sloane.A000073._precompute(10)
sage: len(sloane.A000073._b) - initial == 10
True

_repr_( self)

sage: sloane.A000073._repr_()
'Tribonacci numbers: a(n) = a(n-1) + a(n-2) + a(n-3).'

Class: A000079

class A000079
A000079( self)

Powers of 2: $ a(n) = 2^n$ .

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000079;a
Powers of 2: a(n) = 2^n.
sage: a(0)
1
sage: a(2)
4
sage: a(8)
256
sage: a(100)
1267650600228229401496703205376
sage: a.list(9)
[1, 2, 4, 8, 16, 32, 64, 128, 256]

Author: Jaap Spies (2007-01-18)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000079._eval(n) for n in range(10)]
       [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]

_repr_( self)

sage: sloane.A000079._repr_()
'Powers of 2: a(n) = 2^n.'

Class: A000085

class A000085
A000085( self)

Number of self-inverse permutations on $ n$ letters, also known as involutions; number of Young tableaux with $ n$ cells.

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000085;a
Number of self-inverse permutations on n letters.
sage: a(0)
1
sage: a(1)
1
sage: a(2)
2
sage: a(12)
140152
sage: a.list(13)
[1, 1, 2, 4, 10, 26, 76, 232, 764, 2620, 9496, 35696, 140152]

Author: Jaap Spies (2007-02-03)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000085._eval(n) for n in range(10)]
       [1, 1, 2, 4, 10, 26, 76, 232, 764, 2620]

_repr_( self)

sage: sloane.A000085._repr_()
'Number of self-inverse permutations on n letters.'

Class: A000100

class A000100
A000100( self)

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000100;a
Number of compositions of n in which the maximum part size is 3.
sage: a(0)
0
sage: a(1)
0
sage: a(2)
0
sage: a(3)
1
sage: a(11)
360
sage: a.list(12)
[0, 0, 0, 1, 2, 5, 11, 23, 47, 94, 185, 360]

Author: Jaap Spies (2007-01-26)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000100._eval(n) for n in range(10)]
[0, 0, 0, 1, 2, 5, 11, 23, 47, 94]

_repr_( self)

sage: sloane.A000100._repr_()
'Number of compositions of n in which the maximum part size is 3.'

Class: A000108

class A000108
A000108( self)

Catalan numbers: $ C_n = \frac{{{2n}\choose{n}}}{n+1} = \frac {(2n)!}{n!(n+1)!}$ . Also called Segner numbers.

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000108;a
Catalan numbers: C(n) = binomial(2n,n)/(n+1) = (2n)!/(n!(n+1)!). Also
called Segner numbers.
sage: a(0)
1
sage: a.offset
0
sage: a(8)
1430
sage: a(40)
2622127042276492108820
sage: a.list(9)
[1, 1, 2, 5, 14, 42, 132, 429, 1430]

Author: Jaap Spies (2007-01-12)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000108._eval(n) for n in range(10)]
       [1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862]

_repr_( self)

sage: sloane.A000108._repr_()
'Catalan numbers: C(n) = binomial(2n,n)/(n+1) = (2n)!/(n!(n+1)!). Also
called Segner numbers.'

Class: A000110

class A000110
A000110( self)

The sequence of Bell numbers.

The Bell number $ B_n$ counts the number of ways to put $ n$ distinguishable things into indistinguishable boxes such that no box is empty.

Let $ S(n, k)$ denote the Stirling number of the second kind. Then

$\displaystyle B_n = \sum{k=0}^{n} S(n, k) .$

Input:

n
- integer >= 0

Output:
integer
- $ B_n$

sage: a = sloane.A000110; a
Sequence of Bell numbers
sage: a.offset
0
sage: a(0)
1
sage: a(100)
475853912767648336587907688413872078263636696868256114666163346375591144978
92442622672724044217756306953557882560751
sage: a.list(10)
[1, 1, 2, 5, 15, 52, 203, 877, 4140, 21147]

Author: Nick Alexander

Special Functions: __init__,$ \,$ _repr_

_repr_( self)

sage: sloane.A000110._repr_()
'Sequence of Bell numbers'

Class: A000120

class A000120
A000120( self)

1's-counting sequence: number of 1's in binary expansion of $ n$ .

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000120;a
1's-counting sequence: number of 1's in binary expansion of n.
sage: a(0)
0
sage: a(2)
1
sage: a(12)
2
sage: a.list(12)
[0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3]

Author: Jaap Spies (2007-01-26)

Functions: f

f( self, n)

sage: [sloane.A000120.f(n) for n in range(10)]
[0, 1, 1, 2, 1, 2, 2, 3, 1, 2]

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000120._eval(n) for n in range(10)]
[0, 1, 1, 2, 1, 2, 2, 3, 1, 2]

_repr_( self)

sage: sloane.A000120._repr_()
"1's-counting sequence: number of 1's in binary expansion of n."

Class: A000124

class A000124
A000124( self)

Central polygonal numbers (the Lazy Caterer's sequence): $ n(n+1)/2 + 1$ .

Or, maximal number of pieces formed when slicing a pancake with $ n$ cuts.

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000124;a
Central polygonal numbers (the Lazy Caterer's sequence): n(n+1)/2 + 1.
sage: a(0)
1
sage: a(1)
2
sage: a(2)
4
sage: a(9)
46
sage: a.list(10)
[1, 2, 4, 7, 11, 16, 22, 29, 37, 46]

Author: Jaap Spies (2007-01-25)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000124._eval(n) for n in range(10)]
[1, 2, 4, 7, 11, 16, 22, 29, 37, 46]

_repr_( self)

sage: sloane.A000124._repr_()
"Central polygonal numbers (the Lazy Caterer's sequence): n(n+1)/2 + 1."

Class: A000129

class A000129
A000129( self)

Pell numbers: $ a(0) = 0$ , $ a(1) = 1$ ; for $ n > 1$ , $ a(n) = 2a(n-1) + a(n-2)$ .

Denominators of continued fraction convergents to $ \sqrt 2$ .

See also A001333

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000129;a
Pell numbers: a(0) = 0, a(1) = 1; for n > 1, a(n) = 2*a(n-1) + a(n-2).
sage: a(0)
0
sage: a(2)
2
sage: a(12)
13860
sage: a.list(12)
[0, 1, 2, 5, 12, 29, 70, 169, 408, 985, 2378, 5741]

Author: Jaap Spies (2007-01-25)

Special Functions: __init__,$ \,$ _repr_

_repr_( self)

sage: sloane.A000129._repr_()
'Pell numbers: a(0) = 0, a(1) = 1; for n > 1, a(n) = 2*a(n-1) + a(n-2).'

Class: A000142

class A000142
A000142( self)

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

sage: a = sloane.A000142;a
Factorial numbers: n! = 1*2*3*4*...*n (order of symmetric group S_n, number
of permutations of n letters).
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]

Author: Jaap Spies (2007-01-12)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000142._eval(n) for n in range(10)]
       [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880]

_repr_( self)

sage: sloane.A000142._repr_()
'Factorial numbers: n! = 1*2*3*4*...*n (order of symmetric group S_n,
number of permutations of n letters).'

Class: A000153

class A000153
A000153( self)

$ a(n) = n*a(n-1) + (n-2)*a(n-2)$ , with $ a(0) = 0$ , $ a(1) = 1$ .

With offset 1, permanent of (0,1)-matrix of size $ n \times (n+d)$ with $ d=2$ and $ n$ zeros not on a line. This is a special case of Theorem 2.3 of Seok-Zun Song et al. Extremes of permanents of (0,1)-matrices, p. 201-202.

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000153; a
a(n) = n*a(n-1) + (n-2)*a(n-2), with a(0) = 0, a(1) = 1.
sage: a(0)
0
sage: a(1)
1
sage: a(8)
82508
sage: a(20)
10315043624498196944
sage: a.list(8)
[0, 1, 2, 7, 32, 181, 1214, 9403]

Author: Jaap Spies (2007-01-13)

Special Functions: __init__,$ \,$ _repr_

_repr_( self)

sage: sloane.A000153._repr_()
'a(n) = n*a(n-1) + (n-2)*a(n-2), with a(0) = 0, a(1) = 1.'

Class: A000165

class A000165
A000165( self)

Double factorial numbers: $ (2n)!! = 2^n*n!$ .

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000165;a
Double factorial numbers: (2n)!! = 2^n*n!.
sage: a(0)
1
sage: a.offset
0
sage: a(8)
10321920
sage: a(20)
2551082656125828464640000
sage: a.list(9)
[1, 2, 8, 48, 384, 3840, 46080, 645120, 10321920]

Author: Jaap Spies (2007-01-24)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000165._eval(n) for n in range(10)]
       [1, 2, 8, 48, 384, 3840, 46080, 645120, 10321920, 185794560]

_repr_( self)

sage: sloane.A000165._repr_()
'Double factorial numbers: (2n)!! = 2^n*n!.'

Class: A000166

class A000166
A000166( self)

Subfactorial or rencontres numbers, or derangements: number of permutations of $ n$ elements with no fixed points.

With offset 1 also the permanent of a (0,1)-matrix of order $ n$ with $ n$ 0's not on a line.

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000166;a
Subfactorial or rencontres numbers, or derangements: number of permutations
of $n$ elements with no fixed points.
sage: a(0)
1
sage: a(1)
0
sage: a(2)
1
sage: a.offset
0
sage: a(8)
14833
sage: a(20)
895014631192902121
sage: a.list(9)
[1, 0, 1, 2, 9, 44, 265, 1854, 14833]

Author: Jaap Spies (2007-01-13)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000166._eval(n) for n in range(9)]
[1, 0, 1, 2, 9, 44, 265, 1854, 14833]

_repr_( self)

sage: sloane.A000166._repr_()
'Subfactorial or rencontres numbers, or derangements: number of
permutations of $n$ elements with no fixed points.'

Class: A000169

class A000169
A000169( self)

Number of labeled rooted trees with $ n$ nodes: $ n^{(n-1)}$ .

Input:

n
- positive integer

Output:
integer
- function value

sage: a = sloane.A000169;a
Number of labeled rooted trees with n nodes: n^(n-1).
sage: a(0)
Traceback (most recent call last):
...
ValueError: input n (=0) must be a positive integer
sage: a(1)
1
sage: a(2)
2
sage: a(10)
1000000000
sage: a.list(11)
[1, 2, 9, 64, 625, 7776, 117649, 2097152, 43046721, 1000000000,
25937424601]

Author: Jaap Spies (2007-01-26)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000169._eval(n) for n in range(1,11)]
       [1, 2, 9, 64, 625, 7776, 117649, 2097152, 43046721, 1000000000]

_repr_( self)

sage: sloane.A000169._repr_()
'Number of labeled rooted trees with n nodes: n^(n-1).'

Class: A000203

class A000203
A000203( self)

The sequence $ \sigma(n)$ , where $ \sigma(n)$ is the sum of the divisors of $ n$ . Also called $ \sigma_1(n)$ .

The function sigma(n, k) implements $ \sigma_k(n)$ in SAGE.

Input:

n
- positive integer

Output:
integer
- function value

sage: a = sloane.A000203; a
sigma(n) = sum of divisors of n. Also called sigma_1(n).
sage: a(1)
1
sage: a(0)
Traceback (most recent call last):
...
ValueError: input n (=0) must be a positive integer
sage: a(256)
511
sage: a.list(12)
[1, 3, 4, 7, 6, 12, 8, 15, 13, 18, 12, 28]
sage: a(1/3)
Traceback (most recent call last):
...
TypeError: input must be an int, long, or Integer

Author: Jaap Spies (2007-01-13)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000203._eval(n) for n in range(1,11)]
[1, 3, 4, 7, 6, 12, 8, 15, 13, 18]

_repr_( self)

sage: sloane.A000203._repr_()
'sigma(n) = sum of divisors of n. Also called sigma_1(n).'

Class: A000204

class A000204
A000204( self)

Lucas numbers (beginning with 1): $ L(n) = L(n-1) + L(n-2)$ with $ L(1) = 1$ , $ L(2) = 3$ .

Input:

n
- positive integer

Output:
integer
- function value

sage: a = sloane.A000204; a
Lucas numbers (beginning at 1): L(n) = L(n-1) + L(n-2), L(2) = 3.
sage: a(1)
1
sage: a(8)
47
sage: a(200)
627376215338105766356982006981782561278127
sage: a(-4)
Traceback (most recent call last):
...
ValueError: input n (=-4) must be a positive integer
sage: a.list(12)
[1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322]
sage: a(0)
Traceback (most recent call last):
...
ValueError: input n (=0) must be a positive integer

Author: Jaap Spies (2007-01-18)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000204._eval(n) for n in range(1,11)]
[1, 3, 4, 7, 11, 18, 29, 47, 76, 123]

_repr_( self)

sage: sloane.A000204._repr_()
'Lucas numbers (beginning at 1): L(n) = L(n-1) + L(n-2), L(2) = 3.'

Class: A000213

class A000213
A000213( self)

Tribonacci numbers: a(n) = a(n-1) + a(n-2) + a(n-3). Starting with 1, 1, 1, ...

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000213;a
Tribonacci numbers: a(n) = a(n-1) + a(n-2) + a(n-3).
sage: a(0)
1
sage: a(1)
1
sage: a(2)
1
sage: a(11)
355
sage: a.list(12)
[1, 1, 1, 3, 5, 9, 17, 31, 57, 105, 193, 355]

Author: Jaap Spies (2007-01-19)

Functions: list

list( self, n)

sage: sloane.A000213.list(10)
[1, 1, 1, 3, 5, 9, 17, 31, 57, 105]

Special Functions: __init__,$ \,$ _eval,$ \,$ _precompute,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000213._eval(n) for n in range(10)]
[1, 1, 1, 3, 5, 9, 17, 31, 57, 105]

_precompute( self, [how_many=20])

sage: initial = len(sloane.A000213._b)
sage: sloane.A000213._precompute(10)
sage: len(sloane.A000213._b) - initial == 10
True

_repr_( self)

sage: sloane.A000213._repr_()
'Tribonacci numbers: a(n) = a(n-1) + a(n-2) + a(n-3).'

Class: A000217

class A000217
A000217( self)

Triangular numbers: $ a(n) = {n+1} \choose 2) = n(n+1)/2$ .

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000217;a
Triangular numbers: a(n) = C(n+1,2) = n(n+1)/2 = 0+1+2+...+n.
sage: a(0)
0
sage: a(2)
3
sage: a(8)
36
sage: a(2000)
2001000
sage: a.list(9)
[0, 1, 3, 6, 10, 15, 21, 28, 36]

Author: Jaap Spies (2007-01-25)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000217._eval(n) for n in range(10)]
[0, 1, 3, 6, 10, 15, 21, 28, 36, 45]

_repr_( self)

sage: sloane.A000217._repr_()
'Triangular numbers: a(n) = C(n+1,2) = n(n+1)/2 = 0+1+2+...+n.'

Class: A000225

class A000225
A000225( self)

$ 2^n-1$ .

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000225;a
2^n - 1.
sage: a(0)
0
sage: a(-1)
Traceback (most recent call last):
...
ValueError: input n (=-1) must be an integer >= 0
sage: a(12)
4095
sage: a.list(12)
[0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047]

Author: Jaap Spies (2007-01-25)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000225._eval(n) for n in range(10)]
       [0, 1, 3, 7, 15, 31, 63, 127, 255, 511]

_repr_( self)

sage: sloane.A000225._repr_()
'2^n - 1.'

Class: A000244

class A000244
A000244( self)

Powers of 3: $ a(n) = 3^n$ .

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000244;a
Powers of 3: a(n) = 3^n.
sage: a(-1)
Traceback (most recent call last):
...
ValueError: input n (=-1) must be an integer >= 0
sage: a(0)
1
sage: a(3)
27
sage: a(11)
177147
sage: a.list(12)
[1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147]

Author: Jaap Spies (2007-01-26)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000244._eval(n) for n in range(10)]
       [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683]

_repr_( self)

sage: sloane.A000244._repr_()
'Powers of 3: a(n) = 3^n.'

Class: A000255

class A000255
A000255( self)

$ a(n) = n*a(n-1) + (n-1)*a(n-2)$ , with $ a(0) = 1$ , $ a(1) = 1$ .

With offset 1, permanent of (0,1)-matrix of size $ n \times (n+d)$ with $ d=1$ and $ n$ zeros not on a line. This is a special case of Theorem 2.3 of Seok-Zun Song et al. Extremes of permanents of (0,1)-matrices, p. 201-202.

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000255;a
a(n) = n*a(n-1) + (n-1)*a(n-2), a(0) = 1, a(1) = 1.
sage: a(0)
1
sage: a(1)
1
sage: a.offset
0
sage: a(8)
148329
sage: a(22)
9923922230666898717143
sage: a.list(9)
[1, 1, 3, 11, 53, 309, 2119, 16687, 148329]

Author: Jaap Spies (2007-01-13)

Special Functions: __init__,$ \,$ _repr_

_repr_( self)

sage: sloane.A000255._repr_()
'a(n) = n*a(n-1) + (n-1)*a(n-2), a(0) = 1, a(1) = 1.'

Class: A000261

class A000261
A000261( self)

$ a(n) = n*a(n-1) + (n-3)*a(n-2)$ , with $ a(1) = 1$ , $ a(2) = 1$ .

With offset 1, permanent of (0,1)-matrix of size $ n \times (n+d)$ with $ d=3$ and $ n$ zeros not on a line. This is a special case of Theorem 2.3 of Seok-Zun Song et al. Extremes of permanents of (0,1)-matrices, p. 201-202.

Seok-Zun Song et al., Extremes of permanents of (0,1)-matrices, Lin. Algebra and its Applic. 373 (2003), p. 197-210.

Input:

n
- positive integer

Output:
integer
- function value

sage: a = sloane.A000261;a
a(n) = n*a(n-1) + (n-3)*a(n-2), a(1) = 0, a(2) = 1.
sage: a(0)
Traceback (most recent call last):
...
ValueError: input n (=0) must be a positive integer
sage: a(1)
0
sage: a.offset
1
sage: a(8)
30637
sage: a(22)
1801366114380914335441
sage: a.list(9)
[0, 1, 3, 13, 71, 465, 3539, 30637, 296967]

Author: Jaap Spies (2007-01-23)

Special Functions: __init__,$ \,$ _repr_

_repr_( self)

sage: sloane.A000261._repr_()
'a(n) = n*a(n-1) + (n-3)*a(n-2), a(1) = 0, a(2) = 1.'

Class: A000272

class A000272
A000272( self)

Number of labeled rooted trees on $ n$ nodes: $ n^{(n-2)}$ .

Input:

n
- positive integer

Output:
integer
- function value

sage: a = sloane.A000272;a
Number of labeled rooted trees with n nodes: n^(n-2).
sage: a(0)
Traceback (most recent call last):
...
ValueError: input n (=0) must be a positive integer
sage: a(1)
1
sage: a(2)
1
sage: a(10)
100000000
sage: a.list(11)
[1, 1, 3, 16, 125, 1296, 16807, 262144, 4782969, 100000000, 2357947691]

Author: Jaap Spies (2007-01-26)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000272._eval(n) for n in range(1,11)]
       [1, 1, 3, 16, 125, 1296, 16807, 262144, 4782969, 100000000]

_repr_( self)

sage: sloane.A000272._repr_()
'Number of labeled rooted trees with n nodes: n^(n-2).'

Class: A000290

class A000290
A000290( self)

The squares: $ a(n) = n^2$ .

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000290;a
The squares: a(n) = n^2.
sage: a(0)
0
sage: a(-1)
Traceback (most recent call last):
...
ValueError: input n (=-1) must be an integer >= 0
sage: a(16)
256
sage: a.list(17)
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256]

Author: Jaap Spies (2007-01-25)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000290._eval(n) for n in range(10)]
       [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

_repr_( self)

sage: sloane.A000290._repr_()
'The squares: a(n) = n^2.'

Class: A000292

class A000292
A000292( self)

Tetrahedral (or pyramidal) numbers: $ {n+2} \choose 3 = n(n+1)(n+2)/6$ .

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000292;a
Tetrahedral (or pyramidal) numbers: C(n+2,3) = n(n+1)(n+2)/6.
sage: a(0)
0
sage: a(2)
4
sage: a(11)
286
sage: a.list(12)
[0, 1, 4, 10, 20, 35, 56, 84, 120, 165, 220, 286]

Author: Jaap Spies (2007-01-26)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000292._eval(n) for n in range(10)]
       [0, 1, 4, 10, 20, 35, 56, 84, 120, 165]

_repr_( self)

sage: sloane.A000292._repr_()
'Tetrahedral (or pyramidal) numbers: C(n+2,3) = n(n+1)(n+2)/6.'

Class: A000302

class A000302
A000302( self)

Powers of 4: $ a(n) = 4^n$ .

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000302;a
Powers of 4: a(n) = 4^n.
sage: a(0)
1
sage: a(1)
4
sage: a(2)
16
sage: a(10)
1048576
sage: a.list(12)
[1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304]

Author: Jaap Spies (2007-01-26)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000302._eval(n) for n in range(10)]
[1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144]

_repr_( self)

sage: sloane.A000302._repr_()
'Powers of 4: a(n) = 4^n.'

Class: A000312

class A000312
A000312( self)

Number of labeled mappings from $ n$ points to themselves (endofunctions): $ n^n$ .

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000312;a
Number of labeled mappings from n points to themselves (endofunctions):
n^n.
sage: a(-1)
Traceback (most recent call last):
...
ValueError: input n (=-1) must be an integer >= 0
sage: a(0)
1
sage: a(1)
1
sage: a(9)
387420489
sage: a.list(11)
[1, 1, 4, 27, 256, 3125, 46656, 823543, 16777216, 387420489, 10000000000]

Author: Jaap Spies (2007-01-26)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000312._eval(n) for n in range(10)]
       [1, 1, 4, 27, 256, 3125, 46656, 823543, 16777216, 387420489]

_repr_( self)

sage: sloane.A000312._repr_()
'Number of labeled mappings from n points to themselves (endofunctions):
n^n.'

Class: A000326

class A000326
A000326( self)

Pentagonal numbers: $ n(3n-1)/2$ .

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000326;a
Pentagonal numbers: n(3n-1)/2.
sage: a(0)
0
sage: a(1)
1
sage: a(2)
5
sage: a(10)
145
sage: a.list(12)
[0, 1, 5, 12, 22, 35, 51, 70, 92, 117, 145, 176]
sage: a(1/3)
Traceback (most recent call last):
...
TypeError: input must be an int, long, or Integer

Author: Jaap Spies (2007-01-26)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000326._eval(n) for n in range(10)]
       [0, 1, 5, 12, 22, 35, 51, 70, 92, 117]

_repr_( self)

sage: sloane.A000326._repr_()
'Pentagonal numbers: n(3n-1)/2.'

Class: A000330

class A000330
A000330( self)

Square pyramidal numbers" $ 0^2 + 1^2 \cdots n^2 = n(n+1)(2n+1)/6$ .

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000330;a
Square pyramidal numbers: 0^2+1^2+2^2+...+n^2 = n(n+1)(2n+1)/6.
sage: a(-1)
Traceback (most recent call last):
...
ValueError: input n (=-1) must be an integer >= 0
sage: a(0)
0
sage: a(3)
14
sage: a(11)
506
sage: a.list(12)
[0, 1, 5, 14, 30, 55, 91, 140, 204, 285, 385, 506]

Author: Jaap Spies (2007-01-26)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000330._eval(n) for n in range(10)]
       [0, 1, 5, 14, 30, 55, 91, 140, 204, 285]

_repr_( self)

sage: sloane.A000330._repr_()
'Square pyramidal numbers: 0^2+1^2+2^2+...+n^2 = n(n+1)(2n+1)/6.'

Class: A000396

class A000396
A000396( self)

Perfect numbers: equal to sum of proper divisors.

Input:

n
- positive integer

Output:
integer
- function value

sage: a = sloane.A000396;a
Perfect numbers: equal to sum of proper divisors.
sage: a(0)
Traceback (most recent call last):
...
ValueError: input n (=0) must be a positive integer
sage: a(1)
6
sage: a(2)
28
sage: a(7)
137438691328
sage: a.list(7)
[6, 28, 496, 8128, 33550336, 8589869056, 137438691328]

Author: Jaap Spies (2007-01-25)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000396._eval(n) for n in range(1,6)]
       [6, 28, 496, 8128, 33550336]

_repr_( self)

sage: sloane.A000396._repr_()
'Perfect numbers: equal to sum of proper divisors.'

Class: A000578

class A000578
A000578( self)

The cubes: $ a(n) = n^3$ .

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000578;a
The cubes: n^3
sage: a(-1)
Traceback (most recent call last):
...
ValueError: input n (=-1) must be an integer >= 0
sage: a(0)
0
sage: a(3)
27
sage: a(11)
1331
sage: a.list(12)
[0, 1, 8, 27, 64, 125, 216, 343, 512, 729, 1000, 1331]

Author: Jaap Spies (2007-01-26)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000578._eval(n) for n in range(10)]
       [0, 1, 8, 27, 64, 125, 216, 343, 512, 729]

_repr_( self)

sage: sloane.A000578._repr_()
'The cubes: n^3'

Class: A000583

class A000583
A000583( self)

Fourth powers: $ a(n) = n^4$ .

Input:

n
- non negative integer

Output:
integer
- function value

sage: a = sloane.A000583;a
Fourth powers: n^4.
sage: a(0.0)
Traceback (most recent call last):
...
TypeError: input must be an int, long, or Integer
sage: a(1)
1
sage: a(2)
16
sage: a(9)
6561
sage: a.list(10)
[0, 1, 16, 81, 256, 625, 1296, 2401, 4096, 6561]

Author: Jaap Spies (2007-02-04)

Special Functions: __init__,$ \,$ _eval,$ \,$ _repr_

_eval( self, n)

sage: [sloane.A000583._eval(n) for n in range(10)]
       [0, 1, 16, 81, 256, 625, 1296, 2401, 4096, 6561]

_repr_( self)

sage: sloane.A000583._repr_()
'Fourth powers: n^4.'

Class: A000587

class A000587
A000587( self)

The sequence of Uppuluri-Carpenter numbers.

The Uppuluri-Carpenter number $ C_n$ counts the imbalance in the number of ways to put $ n$ distinguishable things into an even number of indistinguishable boxes versus into an odd number of indistinguishable boxes, such that no box is empty.

Let $ S(n, k)$ denote the Stirling number of the second kind. Then