To look up sequence A060843, type one of the following:
sage: sloane_sequence(60843) # optional - internet
Searching Sloane's online database...
[60843, 'Busy Beaver problem: maximal number of steps that an n-state Turing machine can make on an initially blank tape before eventually halting.', [1, 6, 21, 107]]
sage: sloane_sequence("60843") # optional - internet
Searching Sloane's online database...
[60843, 'Busy Beaver problem: maximal number of steps that an n-state Turing machine can make on an initially blank tape before eventually halting.', [1, 6, 21, 107]]
sage: sloane_sequence("060843") # optional - internet
Searching Sloane's online database...
[60843, 'Busy Beaver problem: maximal number of steps that an n-state Turing machine can make on an initially blank tape before eventually halting.', [1, 6, 21, 107]]
Do not prefix an integer with a 0 or it will be interpreted in octal. Results are of the form [number, description, list], and invalid numbers will cause sloane_sequence to raise an ValueError exception:
sage: sloane_sequence('sage') # optional - internet
...
ValueError: sequence 'sage' not found
To look up the sequence “2, 3, 5, 7”, simply put the numbers in a list. The second argument specifies that at most 2 results will be returned.
sage: sloane_find([2,3,5,7], 2) # optional - internet
Searching Sloane's online database...
[[40, 'The prime numbers.', [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271]], [41, 'a(n) = number of partitions of n (the partition numbers).', [1, 1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 56, 77, 101, 135, 176, 231, 297, 385, 490, 627, 792, 1002, 1255, 1575, 1958, 2436, 3010, 3718, 4565, 5604, 6842, 8349, 10143, 12310, 14883, 17977, 21637, 26015, 31185, 37338, 44583, 53174, 63261, 75175, 89134]]]
To return no more than 3 results (default is 30), type
sage: len(sloane_find([1,2,3,4,5], 3)) # optional - internet
Searching Sloane's online database...
3
Sequence A137443 includes Sage code, and a “b file” that was computed with Sage:
sage: sloane_find([7, 71, 281, 4523, 74713]) # optional - internet
Searching Sloane's online database...
[[137443, 'First n-digit prime in consecutive digits of e.', [7, 71, 281, 4523, 74713, 904523, 6028747, 72407663, 360287471, 7427466391, 75724709369, 749669676277, 8284590452353, 99959574966967, 724709369995957, 2470936999595749, 28459045235360287, 571382178525166427]]]
Note that the OEIS (http://www.research.att.com/ njas/sequences/) claims to limit the number of results to 100. Results are lists of the form [ [number, description, list]], and invalid input will cause sloane_find to return [].
In some cases, these functions may return [] even though the inputs are legal. These cases correspond to errors from the OEIS server, and calling the functions again may fix the problem.
Alternatively, the SloaneEncyclopedia object provides access to a local copy of the database containing only the sequences and their names. To use this you must download and install the database using SloaneEncyclopedia.install(), or SloaneEncyclopedia.install_from_gz() if you have already downloaded the database manually.
To look up a sequence, type
sage: SloaneEncyclopedia[60843] # optional - sloane_database
[1, 6, 21, 107]
To get the name of a sequence, type
sage: SloaneEncyclopedia.sequence_name(1) # optional - sloane_database
'Number of groups of order n.'
To search locally for a particular subsequence, type
sage: SloaneEncyclopedia.find([1,2,3,4,5], 1) # optional - sloane_database
[(15, [1, 2, 3, 4, 5, 7, 7, 8, 9, 11, 11, 13, 13, 16, 16, 16, 17, 19, 19, 23, 23, 23, 23, 25, 25, 27, 27, 29, 29, 31, 31, 32, 37, 37, 37, 37, 37, 41, 41, 41, 41, 43, 43, 47, 47, 47, 47, 49, 49, 53, 53, 53, 53, 59, 59, 59, 59, 59, 59, 61, 61, 64, 64, 64, 67, 67, 67, 71, 71, 71, 71, 73])]
The default maximum number of results is 30, but to return up to 100, type
sage: SloaneEncyclopedia.find([1,2,3,4,5], 100) # optional - sloane_database
[(15, [1, 2, 3, 4, 5, 7, 7, 8, 9, 11, 11, ...
Results in either case are of the form [ (number, list) ].
TODO:
When this program gets a sloane sequence from the database it actually downloads a huge amount of information about it, then throws most of it away. Also, it returns the data to the user as a very simple tuple. It would be much better to return an instance of a class:
class SloaneSequence: ...
and the class should have methods for each of the things that Sloane records about a sequence. Also, when possible, it should be able to compute more terms.
AUTHORS:
A local copy of the Sloane Online Encyclopedia of Integer Sequences that contains only the sequence numbers and the sequences themselves.
Return a list of all sequences which have seq as a subsequence, up to maxresults results. Sequences are returned in the form (number, list).
INPUT:
OUTPUT: list of 2-tuples (i, v), where v is a sequence with seq as a subsequence.
Download and install the online encyclopedia, raising an IOError if either step fails.
INPUT:
Install the online encyclopedia from a local stripped.gz file.
INPUT:
Return the name of sequence N in the encyclopedia. If sequence N does not exist, return ‘’. If the names database is not installed, raise an IOError.
INPUT:
OUTPUT: string
EXAMPLES:
sage: SloaneEncyclopedia.sequence_name(1) # optional - sloane_database ‘Number of groups of order n.’
Decompress a gzipped file and install the bzipped verson. This is used by SloaneEncyclopedia.install_from_gz to install several gzipped OEIS database files.
INPUT:
Searches Sloane’s Online Encyclopedia of Integer Sequences for a sequence containing the number provided in list.
INPUT:
OUTPUT: A list of matches in Sloane’s database. Each match consists of a list of the sequence number, the name of the sequence, and some initial terms of the sequence.
EXAMPLES:
sage: sloane_find([1,1,2,3,5,8,13,21], nresults=1) #optional - internet
Searching Sloane's online database...
[[45,
'Fibonacci numbers: F(n) = F(n-1) + F(n-2), F(0) = 0, F(1) = 1, F(2) = 1, ...',
[0,
1,
1,
2,
3,
5,
8,
13,
21,
...
39088169]]]
Returns a list with the number, name, and values for the sequence number in Sloane’s online database of integer sequences.
EXAMPLES:
sage: sloane_sequence(22) # optional - internet
Searching Sloane's online database...
[22,
'Number of centered hydrocarbons with n atoms.',
[0,
1,
0,
1,
...
36201693122]]
The input must not be a sequence itself:
sage: sloane_sequence(prime_range(100))
...
TypeError: input must be an integer or string that specifies the id of the Sloane sequence to download