Name | OEISsequences JSON |

Version | 0.2.4.3 JSON |

download | |

home_page | https://github.com/postvakje/oeis-sequences |

Summary | Python functions to generate OEIS sequences |

upload_time | 2024-10-09 01:01:24 |

maintainer | None |

docs_url | None |

author | Chai Wah Wu |

requires_python | >=3.8 |

license | LICENSE |

keywords | |

VCS | |

bugtrack_url | |

requirements | sympy gmpy2 num2words unidecode networkx bitarray |

Travis-CI | No Travis. |

coveralls test coverage | No coveralls. |

# oeis-sequences [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) Python functions to generate [The On-Line Encyclopedia of Integer Sequences](https://oeis.org/) (OEIS) sequences. Python is the ideal language for this purpose because of the following reasons: 1. Python is a general purpose programming language with support for file I/O and graphing. 2. Arbitrary size integer format is standard in Python. This is important as many sequences in OEIS contain very large integers that will not fit in 64-bit integer formats. This allows the implemented functions to generate terms for arbitrary large `n` and they do not depend on floating point precision. For higher performance, one can use [`gmpy2`](https://pypi.org/project/gmpy2/). 3. There exists extensive modules for combinatorics and number theory such as `math`, `itertools` and [`sympy`](https://www.sympy.org/en/index.html). Although Python can be slow as it is an interpreted language, this can be mitigated somewhat using tools such as [`pypy`](https://www.pypy.org/) and [`numba`](https://numba.pydata.org/). ## 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 (up to) 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`. This keyword is only available on sequences that are nondecreasing. 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)<sup>m</sup> 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 n<sup>3</sup> 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))) # print first 10 terms >= 1475 >> [1475, 1484, 1531, 1706, 1721, 1733, 1818, 1844, 1895, 1903] ``` ## Utility functions The module also includes some utility functions for exploring integer sequences in OEIS such as palindrome generator, Boustrophedon transform, run length transform, Faulhaber's formula, lunar arithmetic, squarefree numbers, *k*-almost primes, squarefree *k*-almost primes, etc.

{ "_id": null, "home_page": "https://github.com/postvakje/oeis-sequences", "name": "OEISsequences", "maintainer": null, "docs_url": null, "requires_python": ">=3.8", "maintainer_email": null, "keywords": null, "author": "Chai Wah Wu", "author_email": "cwwuieee@gmail.com", "download_url": "https://files.pythonhosted.org/packages/27/5e/326a46a1e5a268958f8dfd275450cc1983e1ff1fab248512dc29eafd31c8/OEISsequences-0.2.4.3.tar.gz", "platform": null, "description": "# oeis-sequences\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\nPython functions to generate [The On-Line Encyclopedia of Integer Sequences](https://oeis.org/) (OEIS) sequences.\n\nPython is the ideal language for this purpose because of the following reasons:\n\n1. Python is a general purpose programming language with support for file I/O and graphing.\n2. Arbitrary size integer format is standard in Python. This is important as many sequences in OEIS contain very large integers that will not fit in 64-bit integer formats. This allows the implemented functions to generate terms for arbitrary large `n` and they do not depend on floating point precision. For higher performance, one can use [`gmpy2`](https://pypi.org/project/gmpy2/).\n3. There exists extensive modules for combinatorics and number theory such as `math`, `itertools` and [`sympy`](https://www.sympy.org/en/index.html).\n\nAlthough Python can be slow as it is an interpreted language, this can be mitigated somewhat using tools such as [`pypy`](https://www.pypy.org/) and [`numba`](https://numba.pydata.org/).\n\n## Requirements\nRequires `python` >= 3.8\n\n## Installation\n`pip install OEISsequences`\n\n## Usage\nAfter installation, `from oeis_sequences import OEISsequences` will import all the functions accessible via `OEISsequences.Axxxxxx`.\nAlternatively, invidividual functions can be imported as `from oeis_sequences.OEISsequences import Axxxxxx`.\n\nFor each sequence, there are (up to) 3 different kinds of functions:\n\n1. Functions named `Axxxxxx`: Axxxxxx(n) returns the *n*-th term of OEIS sequence Axxxxxx.\n\n2. Functions named `Axxxxxx_T`: returns T(n,k) for OEIS sequences where the natural definition is a 2D table *T*.\n\n3. Functions named `Axxxxxx_gen`: Axxxxxx_gen() returns a generator of OEIS sequence Axxxxxx.\n\nThe 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. \n\nFor the generator, we can for example use `list(islice(Axxxxxx_gen(),10))` to return the first 10 terms of sequence Axxxxxx\nAlternatively, setting `gen = Axxxxxx_gen()` and using `next(gen)` returns the next term of the sequence.\n\nGiven `Axxxxxx_gen`, one can define a function `Axxxxxx` as: \n\n```\ndef Axxxxxx(n,offset=1): return next(islice(Axxxxxx_gen(),n-offset,None))\n```\n\nwhere 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.\n\nSome functions `Axxxxxx_gen` contain an optional keyword `startvalue` that returns a generator of terms that are larger than or equal to `startvalue`. This keyword is only available on sequences that are nondecreasing.\n\nFor some sequences, e.g. `A269483`, both types of functions `Axxxxxx` and `Axxxxxx_gen` are provided.\n\n## Examples\n\nLeast power of 3 having exactly n consecutive 7's in its decimal representation.\n``` \nfrom oeis_sequences.OEISsequences import A131546\nprint(A131546(5))\n>> 721\n``` \nMinimal exponents m such that the fractional part of (10/9)<sup>m</sup> obtains a maximum (when starting with m=1). \n```\nfrom itertools import islice\nfrom oeis_sequences.OEISsequences import A153695_gen\nprint(list(islice(A153695_gen(),10)))\n>> [1, 2, 3, 4, 5, 6, 13, 17, 413, 555]\n```\n\nNumbers n such that n<sup>3</sup> has one or more occurrences of exactly nine different digits.\n```\nfrom oeis_sequences.OEISsequences import A235811_gen \nprint(list(islice(A235811_gen(startvalue=1475),10))) # print first 10 terms >= 1475\n>> [1475, 1484, 1531, 1706, 1721, 1733, 1818, 1844, 1895, 1903]\n```\n\n## Utility functions\nThe module also includes some utility functions for exploring integer sequences in OEIS such as palindrome generator, Boustrophedon transform, run length transform, Faulhaber's formula, lunar arithmetic, squarefree numbers, *k*-almost primes, squarefree *k*-almost primes, etc.\n", "bugtrack_url": null, "license": "LICENSE", "summary": "Python functions to generate OEIS sequences", "version": "0.2.4.3", "project_urls": { "Homepage": "https://github.com/postvakje/oeis-sequences" }, "split_keywords": [], "urls": [ { "comment_text": "", "digests": { "blake2b_256": "89fe6e6ab6e695a4d4992d328ba9a6a48834ff36e44517c47e3c66e9fac7a882", "md5": "0fddc46ca575d9ac9e1124b54d808bae", "sha256": "537ed57b9f147b738c5cb7de73187bbab16d1b20deeeaa122583d9a2fd430342" }, "downloads": -1, "filename": "OEISsequences-0.2.4.3-py3-none-any.whl", "has_sig": false, "md5_digest": "0fddc46ca575d9ac9e1124b54d808bae", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.8", "size": 278521, "upload_time": "2024-10-09T01:01:22", "upload_time_iso_8601": "2024-10-09T01:01:22.146286Z", "url": "https://files.pythonhosted.org/packages/89/fe/6e6ab6e695a4d4992d328ba9a6a48834ff36e44517c47e3c66e9fac7a882/OEISsequences-0.2.4.3-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "blake2b_256": "275e326a46a1e5a268958f8dfd275450cc1983e1ff1fab248512dc29eafd31c8", "md5": "367f6034f4c0c07f162c90d9b06da023", "sha256": "b8d9561beeee284bff43f4684edcbd85dd008d8fb51512dda62b255828ea9acb" }, "downloads": -1, "filename": "OEISsequences-0.2.4.3.tar.gz", "has_sig": false, "md5_digest": "367f6034f4c0c07f162c90d9b06da023", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.8", "size": 266673, "upload_time": "2024-10-09T01:01:24", "upload_time_iso_8601": "2024-10-09T01:01:24.188093Z", "url": "https://files.pythonhosted.org/packages/27/5e/326a46a1e5a268958f8dfd275450cc1983e1ff1fab248512dc29eafd31c8/OEISsequences-0.2.4.3.tar.gz", "yanked": false, "yanked_reason": null } ], "upload_time": "2024-10-09 01:01:24", "github": true, "gitlab": false, "bitbucket": false, "codeberg": false, "github_user": "postvakje", "github_project": "oeis-sequences", "travis_ci": false, "coveralls": false, "github_actions": false, "requirements": [ { "name": "sympy", "specs": [] }, { "name": "gmpy2", "specs": [] }, { "name": "num2words", "specs": [] }, { "name": "unidecode", "specs": [] }, { "name": "networkx", "specs": [] }, { "name": "bitarray", "specs": [] } ], "lcname": "oeissequences" }

Elapsed time: 0.45765s