Skip to main content

Python functions to generate OEIS sequences

Project description

oeis-sequences

Code style: black

Python functions to generate The On-Line Encyclopedia of Integer Sequences (OEIS) sequences

Requirements

Requires python >= 3.8

Installation

pip install OEISsequences

Usage

After installation, from oeis_sequences import OEISsequences will import all the functions accessible via OEISsequences.Axxxxxx. Alternatively, invidividual functions can be imported as from oeis_sequences.OEISsequences import Axxxxxx.

For each sequence, there are 3 different kinds of functions:

  1. Functions named Axxxxxx: Axxxxxx(n) returns the n-th term of OEIS sequence Axxxxxx.

  2. Functions named Axxxxxx_T: returns T(n,k) for OEIS sequences where the natural definition is a 2D table T.

  3. Functions named Axxxxxx_gen: Axxxxxx_gen() returns a generator of OEIS sequence Axxxxxx.

The function Axxxxxx is best used to compute a single term. The generator Axxxxxx_gen is typically defined for sequences where terms are best generated sequentially and is best used when computing a sequence of consecutive terms.

For the generator, we can for example use list(islice(Axxxxxx_gen(),10)) to return the first 10 terms of sequence Axxxxxx Alternatively, setting gen = Axxxxxx_gen() and using next(gen) returns the next term of the sequence.

Given Axxxxxx_gen, one can define a function Axxxxxx as:

def Axxxxxx(n,offset=1): return next(islice(Axxxxxx_gen(),n-offset,None))

where a(offset) is the first term returned by the generator. This value of offset is the same as the offset parameter in the OEIS database.

Some functions Axxxxxx_gen contain an optional keyword startvalue that returns a generator of terms that are larger than or equal to startvalue.

For some sequences, e.g. A269483, both types of functions Axxxxxx and Axxxxxx_gen are provided.

Examples

Least power of 3 having exactly n consecutive 7's in its decimal representation.

from oeis_sequences.OEISsequences import A131546
print(A131546(5))
>> 721

Minimal exponents m such that the fractional part of (10/9)m obtains a maximum (when starting with m=1).

from itertools import islice
from oeis_sequences.OEISsequences import A153695_gen
print(list(islice(A153695_gen(),10)))
>> [1, 2, 3, 4, 5, 6, 13, 17, 413, 555]

Numbers n such that n3 has one or more occurrences of exactly nine different digits.

from oeis_sequences.OEISsequences import A235811_gen 
print(list(islice(A235811_gen(startvalue=1475),10)))
>> [1475, 1484, 1531, 1706, 1721, 1733, 1818, 1844, 1895, 1903]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

OEISsequences-0.0.7.tar.gz (101.1 kB view details)

Uploaded Source

Built Distribution

OEISsequences-0.0.7-py3-none-any.whl (105.5 kB view details)

Uploaded Python 3

File details

Details for the file OEISsequences-0.0.7.tar.gz.

File metadata

  • Download URL: OEISsequences-0.0.7.tar.gz
  • Upload date:
  • Size: 101.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.4

File hashes

Hashes for OEISsequences-0.0.7.tar.gz
Algorithm Hash digest
SHA256 7263546574e4a98dac935a93b7a50141c9573ae11e8e87084bbf99f5695bc3bf
MD5 5e52c8e23a972a87e53f66b06aaf8394
BLAKE2b-256 346b60a2a50fdc56be6021f93f083a73c37e164444260aa04b02f54bdac665af

See more details on using hashes here.

Provenance

File details

Details for the file OEISsequences-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: OEISsequences-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 105.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.4

File hashes

Hashes for OEISsequences-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 93fc3c3fba85ac939bcbfcc7877c7669410429d5585d454cd945b2b8a95b7651
MD5 9cf7174d6b18e141ecd5d50a47eedd30
BLAKE2b-256 4e40c4774c72fd91366dd6b1b3b14b943fa1cb1d236633bdfc10ac0ffc850511

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page