EXAMPLES:
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
We agree with the online database::
sage: for t in sloane.trait_names(): # long time optional, requires internet
... online_list = sloane_sequence(ZZ(t[1:].lstrip('0')), verbose = False)[2]
... L = max(2, len(online_list) // 2)
... sage_list = sloane.__getattribute__(t).list(L)
... if online_list[:L] != sage_list:
... print t, 'seems wrong'
AUTHORS:
Bases: sage.combinat.sloane_functions.SloaneSequence
EXAMPLES:
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]
EXAMPLES:
sage: sloane.A000009.list(14)
[1, 1, 1, 2, 2, 3, 4, 5, 6, 8, 10, 12, 15, 18]
Bases: sage.combinat.sloane_functions.SloaneSequence
Returns a generator over all Fibonacci numbers, starting with 0.
EXAMPLES:
sage: it = sloane.A000045.fib()
sage: [it.next() for i in range(10)]
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
EXAMPLES:
sage: sloane.A000045.list(10)
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
Bases: sage.combinat.sloane_functions.SloaneSequence
EXAMPLES:
sage: sloane.A000073.list(10)
[0, 0, 1, 1, 2, 4, 7, 13, 24, 44]
Bases: sage.combinat.sloane_functions.SloaneSequence
EXAMPLES:
sage: [sloane.A000120.f(n) for n in range(10)]
[0, 1, 1, 2, 1, 2, 2, 3, 1, 2]
Bases: sage.combinat.sloane_functions.ExtremesOfPermanentsSequence
Bases: sage.combinat.sloane_functions.SloaneSequence
EXAMPLES:
sage: sloane.A000213.list(10)
[1, 1, 1, 3, 5, 9, 17, 31, 57, 105]
Bases: sage.combinat.sloane_functions.ExtremesOfPermanentsSequence
Bases: sage.combinat.sloane_functions.ExtremesOfPermanentsSequence
Bases: sage.combinat.sloane_functions.SloaneSequence
EXAMPLES:
sage: sloane.A000796.list(10)
[3, 1, 4, 1, 5, 9, 2, 6, 5, 3]
Based on an algorithm of Lambert Meertens The ABC-programming language!!!
EXAMPLES:
sage: it = sloane.A000796.pi()
sage: [it.next() for i in range(10)]
[3, 1, 4, 1, 5, 9, 2, 6, 5, 3]
Bases: sage.combinat.sloane_functions.SloaneSequence
EXAMPLES:
sage: sloane.A000961.list(10)
[1, 2, 3, 4, 5, 7, 8, 9, 11, 13]
Bases: sage.combinat.sloane_functions.SloaneSequence
EXAMPLES:
sage: sloane.A001055.nwf(4,1)
0
sage: sloane.A001055.nwf(4,2)
1
sage: sloane.A001055.nwf(4,3)
1
sage: sloane.A001055.nwf(4,4)
2
Bases: sage.combinat.sloane_functions.RecurrenceSequence
EXAMPLES:
sage: sloane.A001110.g(2)
2
sage: sloane.A001110.g(1)
0
Bases: sage.combinat.sloane_functions.SloaneSequence
EXAMPLES:
sage: sloane.A001358.list(9)
[4, 6, 9, 10, 14, 15, 21, 22, 25]
Bases: sage.combinat.sloane_functions.SloaneSequence
This function returns True if and only if is a Powerful
Number:
A positive integer is powerful if for every prime
dividing
,
also divides
. See Sloane’s OEIS A001694.
INPUT:
OUTPUT:
EXAMPLES:
sage: a = sloane.A001694
sage: a.is_powerful(2500)
True
sage: a.is_powerful(20)
False
AUTHORS:
EXAMPLES:
sage: sloane.A001694.list(9)
[1, 4, 8, 9, 16, 25, 27, 32, 36]
Bases: sage.combinat.sloane_functions.SloaneSequence
EXAMPLES:
sage: sloane.A001836.list(9)
[53, 83, 158, 263, 293, 368, 578, 683, 743]
Bases: sage.combinat.sloane_functions.ExtremesOfPermanentsSequence
Bases: sage.combinat.sloane_functions.ExtremesOfPermanentsSequence
Bases: sage.combinat.sloane_functions.SloaneSequence
EXAMPLES:
sage: sloane.A002113.list(15)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55]
Bases: sage.combinat.sloane_functions.SloaneSequence
EXAMPLES:
sage: sloane.A002808.list(10)
[4, 6, 8, 9, 10, 12, 14, 15, 16, 18]
Bases: sage.combinat.sloane_functions.SloaneSequence
EXAMPLES:
sage: sloane.A005100.list(10)
[1, 2, 3, 4, 5, 7, 8, 9, 10, 11]
Bases: sage.combinat.sloane_functions.SloaneSequence
EXAMPLES:
sage: sloane.A005101.list(10)
[12, 18, 20, 24, 30, 36, 40, 42, 48, 54]
Bases: sage.combinat.sloane_functions.SloaneSequence
EXAMPLES:
sage: sloane.A005117.list(10)
[1, 2, 3, 5, 6, 7, 10, 11, 13, 14]
Bases: sage.combinat.sloane_functions.SloaneSequence
Double factorials n!!: a(n)=n*a(n-2).
EXAMPLES:
sage: it = sloane.A006882.df()
sage: [it.next() for i in range(10)]
[1, 1, 2, 3, 8, 15, 48, 105, 384, 945]
EXAMPLES:
sage: sloane.A006882.list(10)
[1, 1, 2, 3, 8, 15, 48, 105, 384, 945]
Bases: sage.combinat.sloane_functions.SloaneSequence
EXAMPLES:
sage: sloane.A008275.s(4,2)
11
sage: sloane.A008275.s(5,2)
-50
sage: sloane.A008275.s(5,3)
35
Bases: sage.combinat.sloane_functions.SloaneSequence
Returns the Stirling number S2(n,k) of the 2nd kind.
EXAMPLES:
sage: sloane.A008277.s2(4,2)
7
Bases: sage.combinat.sloane_functions.SloaneSequence
EXAMPLES:
sage: sloane.A020639.list(10)
[1, 2, 3, 2, 5, 2, 7, 2, 3, 2]
Bases: sage.combinat.sloane_functions.SloaneSequence
Excess of = number of prime divisors (with
multiplicity) - number of prime divisors (without multiplicity).
.
INPUT:
OUTPUT:
EXAMPLES:
sage: a = sloane.A046660; a
Excess of n = Bigomega (with multiplicity) - omega (without multiplicity).
sage: a(0)
Traceback (most recent call last):
...
ValueError: input n (=0) must be a positive integer
sage: a(1)
0
sage: a(8)
2
sage: a(41)
0
sage: a(84792)
2
sage: a.list(12)
[0, 0, 0, 1, 0, 0, 0, 2, 1, 0, 0, 1]
AUTHORS:
- Jaap Spies (2007-01-19)
Bases: sage.combinat.sloane_functions.RecurrenceSequence
EXAMPLES:
sage: sloane.A051959.g(2)
15
sage: sloane.A051959.g(1)
0
Bases: sage.combinat.sloane_functions.ExtremesOfPermanentsSequence2
Bases: sage.combinat.sloane_functions.SloaneSequence
function returns solutions to the Dancing School problem with
girls and
boys.
The value is , the permanent of the (0,1)-matrix
of size
with
if and only if
.
REFERENCES:
INPUT:
OUTPUT:
EXAMPLES:
sage: a = sloane.A079922; a
Solutions to the Dancing School problem with n girls and n+3 boys
sage: a.offset
1
sage: a(1)
4
sage: a(8)
2227
sage: a.list(8)
[4, 13, 36, 90, 212, 478, 1044, 2227]
Compare: Searching Sloane’s online database... Solution to the Dancing School Problem with n girls and n+3 boys: f(n,3). [4, 13, 36, 90, 212, 478, 1044, 2227]
sage: a(-1)
Traceback (most recent call last):
...
ValueError: input n (=-1) must be a positive integer
AUTHORS:
- Jaap Spies (2007-01-14)
Bases: sage.combinat.sloane_functions.SloaneSequence
function returns solutions to the Dancing School problem with
girls and
boys.
The value is , the permanent of the (0,1)-matrix
of size
with
if and only if
.
REFERENCES:
INPUT:
OUTPUT:
EXAMPLES:
sage: a = sloane.A079923; a
Solutions to the Dancing School problem with n girls and n+4 boys
sage: a.offset
1
sage: a(1)
5
sage: a(8)
15458
sage: a.list(8)
[5, 21, 76, 246, 738, 2108, 5794, 15458]
Compare: Searching Sloane’s online database... Solution to the Dancing School Problem with n girls and n+4 boys: f(n,4). [5, 21, 76, 246, 738, 2108, 5794, 15458]
sage: a(0)
Traceback (most recent call last):
...
ValueError: input n (=0) must be a positive integer
AUTHORS:
- Jaap Spies (2007-01-17)
Bases: sage.combinat.sloane_functions.ExtremesOfPermanentsSequence2
Bases: sage.combinat.sloane_functions.SloaneSequence
The th term of the sequence
is the
largest
such that
can be written as sum of
consecutive integers.
By definition, is the sum of at most
consecutive
positive integers. Suppose
is to be written as sum of
consecutive integers starting with
, then
. Only one of the factors is odd. For each odd divisor
of
there is a unique corresponding
.
can be alternatively defined as the
largest among those
.
See also
INPUT:
OUTPUT:
EXAMPLES:
sage: a = sloane.A109814; a
a(n) is the largest k such that n can be written as sum of k consecutive positive integers.
sage: a(0)
Traceback (most recent call last):
...
ValueError: input n (=0) must be a positive integer
sage: a(2)
1
sage: a.list(9)
[1, 1, 2, 1, 2, 3, 2, 1, 3]
AUTHORS:
Bases: sage.combinat.sloane_functions.SloaneSequence
This function returns True if and only if is a number
of the third kind.
A number is of the third kind if it can be written as a sum of at
least three consecutive positive integers. Odd primes can only be
written as a sum of two consecutive integers. Powers of 2 do not
have a representation as a sum of consecutive integers
(other than the trivial
for
).
See: http://www.jaapspies.nl/mathfiles/problem2005-2C.pdf
INPUT:
OUTPUT:
EXAMPLES:
sage: a = sloane.A111774
sage: a.is_number_of_the_third_kind(6)
True
sage: a.is_number_of_the_third_kind(100)
True
sage: a.is_number_of_the_third_kind(16)
False
sage: a.is_number_of_the_third_kind(97)
False
AUTHORS:
EXAMPLES:
sage: sloane.A111774.list(12)
[6, 9, 10, 12, 14, 15, 18, 20, 21, 22, 24, 25]
Bases: sage.combinat.sloane_functions.SloaneSequence
EXAMPLES:
sage: it = sloane.A000153.gen(0,1,2)
sage: [it.next() for i in range(5)]
[0, 1, 2, 7, 32]
EXAMPLES:
sage: sloane.A000153.list(8)
[0, 1, 2, 7, 32, 181, 1214, 9403]
Bases: sage.combinat.sloane_functions.ExtremesOfPermanentsSequence
EXAMPLES:
sage: from sage.combinat.sloane_functions import ExtremesOfPermanentsSequence2
sage: e = ExtremesOfPermanentsSequence2()
sage: it = e.gen(6,43,6)
sage: [it.next() for i in range(5)]
[6, 43, 307, 2542, 23799]
Bases: sage.combinat.sloane_functions.SloaneSequence
EXAMPLES:
sage: sloane.A001110.list(8)
[0, 1, 36, 1225, 41616, 1413721, 48024900, 1631432881]
Bases: sage.combinat.sloane_functions.SloaneSequence
EXAMPLES:
sage: sloane.A001906.list(10)
[0, 1, 3, 8, 21, 55, 144, 377, 987, 2584]
Bases: sage.structure.sage_object.SageObject
A collection of Sloane generating functions.
This class inspects sage.combinat.sloane_functions, accumulating all the SloaneSequence classes starting with ‘A’. These are listed for tab completion, but not instantiated until requested.
EXAMPLES: Ensure we have lots of entries:
sage: len(sloane.trait_names()) > 100
True
And ensure none are being incorrectly returned:
sage: [ None for n in sloane.trait_names() if not n.startswith('A') ]
[]
Ensure we can access dynamic constructions and cache correctly:
sage: s = sloane.A000587
sage: s is sloane.A000587
True
And that we can access other functions in parent classes:
sage: sloane.__class__
<class 'sage.combinat.sloane_functions.Sloane'>
AUTHORS:
List Sloane generating functions for tab-completion. The member classes are inspected from module sage.combinat.sloane_functions.
They must be sub classes of SloaneSequence and must start with ‘A’. These restrictions are only to prevent typos, incorrect inspecting, etc.
EXAMPLES:
sage: type(sloane.trait_names())
<type 'list'>
Bases: sage.structure.sage_object.SageObject
Base class for a Sloane integer sequence.
EXAMPLES:
We create a dummy sequence:
Return n terms of the sequence: sequence[offset], sequence[offset+1], ... , sequence[offset+n-1]. EXAMPLES:
sage: sloane.A000012.list(4)
[1, 1, 1, 1]
This functions calculates from Sloane’s sequences
A079908-A079928
INPUT:
OUTPUT: permanent of the m x (m+h) matrix, etc.
EXAMPLES:
sage: from sage.combinat.sloane_functions import perm_mh
sage: perm_mh(3,3)
36
sage: perm_mh(3,4)
76
AUTHORS:
homogeneous 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)
EXAMPLES:
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]
inhomogenous second-order linear recurrence generator with fixed
coefficients and
,
,
.
EXAMPLES:
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]
homogeneous 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)
EXAMPLES:
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]