Skip to main content

A collection of functions to play with Lychrel numbers and other funny mathematical problems

Project description

Lychrel

PyPI version Documentation Status

This is a collection of python functions which implements famous mathematical problems, and it is named after the lychrel numbers.

Under the hood lychrel is implemented in rust thanks to PyO3.

User guide and documentation: lychrel.readthedocs.io

Any contribution is welcome!

Implemented algorithms

  • Lychrel numbers: find first palindrome of the reverse-and-add procedure and determine if a number is a lychrel candidate.
  • Generalized fibonacci sequences: also known as Lucas Sequence.
  • Read out and loud: Given a number, this function compute the sequence of digits resulting from reading out loud the number, grouping together multiples of the same digit if any. E.g. read_out_loud(3211) == 131221 because the number 3211 is read as "one 3, one 2 and two 1s".
  • Kaprekar's routine: an iterative algorithm that, with each iteration, takes a natural number in a given number base, creates two new numbers by sorting the digits of its number by descending and ascending order, and subtracts the second from the first to yield the natural number for the next iteration.
  • Collatz conjecture: also known as 3n+1 problem, implements an iterator given a starting number. E.g. list(collatz(5)) == [5, 16, 8, 4, 2, 1].

Getting started

Lychrel is available on PyPi, to install it just type on your favourite shell:

pip install lychrel

Install from source

If you want to install lychrel from source code, clone this repo and create a virtual environment with python 3.7+ using your favourite tool (conda, virtualenv, etc.), then follow these steps:

1. Install dev requirements

pip install -r requirements-dev.txt

2. Build the package

maturin develop

For optimal performances add the --release option:

maturin develop --release

Examples

Check whether a number is a lychrel candidate:

from lychrel import is_lychrel_candidate

assert is_lychrel_candidate(196)
assert not is_lychrel_candidate(197)

Check out the tests for more examples.

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

lychrel-0.7.2.tar.gz (13.3 kB view details)

Uploaded Source

Built Distributions

lychrel-0.7.2-cp37-abi3-win_amd64.whl (162.5 kB view details)

Uploaded CPython 3.7+ Windows x86-64

lychrel-0.7.2-cp37-abi3-win32.whl (150.3 kB view details)

Uploaded CPython 3.7+ Windows x86

lychrel-0.7.2-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ x86-64

lychrel-0.7.2-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.4 MB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ s390x

lychrel-0.7.2-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.3 MB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ppc64le

lychrel-0.7.2-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.2 MB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARMv7l

lychrel-0.7.2-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARM64

lychrel-0.7.2-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl (1.2 MB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.5+ i686

lychrel-0.7.2-cp37-abi3-macosx_11_0_arm64.whl (289.6 kB view details)

Uploaded CPython 3.7+ macOS 11.0+ ARM64

lychrel-0.7.2-cp37-abi3-macosx_10_7_x86_64.whl (299.4 kB view details)

Uploaded CPython 3.7+ macOS 10.7+ x86-64

File details

Details for the file lychrel-0.7.2.tar.gz.

File metadata

  • Download URL: lychrel-0.7.2.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.3.1

File hashes

Hashes for lychrel-0.7.2.tar.gz
Algorithm Hash digest
SHA256 04c6025029e186af9ff22be2e4aacfb9f88e5b3f9f08e5bbef66f67ce9393eb1
MD5 0ee4f06b95fe52818289d2f3e501c0d8
BLAKE2b-256 fbcd224601e5460eb057064fec1a56222661aa334376a79523f1710c1fc8358d

See more details on using hashes here.

File details

Details for the file lychrel-0.7.2-cp37-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for lychrel-0.7.2-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 19b82885945c1ec39a01a12e89db8b63176e25a80626dd49c9a44a4dcccf771e
MD5 b0e946ad4f3c90d8b447cef4814d177f
BLAKE2b-256 5e35816c1132a4f354dd3adab1b78557cc1294d4314f6218b618866532f6141a

See more details on using hashes here.

File details

Details for the file lychrel-0.7.2-cp37-abi3-win32.whl.

File metadata

  • Download URL: lychrel-0.7.2-cp37-abi3-win32.whl
  • Upload date:
  • Size: 150.3 kB
  • Tags: CPython 3.7+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.3.1

File hashes

Hashes for lychrel-0.7.2-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 fc9359f12c8229a75343d0b2a599ee6b6679394f96cb7c31bbd86e7b06e63f59
MD5 828536f0bdfa2b29457900324ae6cb0e
BLAKE2b-256 4285b2e949c35562d4b4d48963a7cc2dd918b0310485493cd5ce296eb04d9a34

See more details on using hashes here.

File details

Details for the file lychrel-0.7.2-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lychrel-0.7.2-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 31f0041c8fe589656461faa5a1a2ee22c861af8f1206e413bf5c0fc2c52e82bc
MD5 3411f00489d65310a3eb5686d3bc8579
BLAKE2b-256 0225e274add0fa753ba94ee6a607c4b5b49525f66cc04a9c818c007aece4bcaf

See more details on using hashes here.

File details

Details for the file lychrel-0.7.2-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for lychrel-0.7.2-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 4b1464c7af013fd50890bfbca99c8161ffd5919fb5324a8a933558188af3d592
MD5 d79828cf14459cdc6a79919215ac61c9
BLAKE2b-256 f7fa297996e6db9d238945cb1b0f7a0e902c658651886fcd47b4f1d248b678f9

See more details on using hashes here.

File details

Details for the file lychrel-0.7.2-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for lychrel-0.7.2-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 995eb82d108af9deed1bb7472288c69c30d390c5c2aa0e9cae978d0035b68259
MD5 fe4e82570dae607898551769520de47a
BLAKE2b-256 b0717e21d79d99296859d2530b7b37231ed657c73983d1851033e5602695daaf

See more details on using hashes here.

File details

Details for the file lychrel-0.7.2-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for lychrel-0.7.2-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 8662193713d1c2ee89806b081168b3dbdae542c672908a7e6599e2ef6ebcc258
MD5 5c1eed86b86a8c3d09bea382cf049c85
BLAKE2b-256 f58427ac0fcc07188b93d69a1318a0d1db247da2a0eeee48bc4701335cec2274

See more details on using hashes here.

File details

Details for the file lychrel-0.7.2-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for lychrel-0.7.2-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1379757b79fe80d7f0467673bd10145c2dbe3392eae1f1d42dc7d5931235ad29
MD5 cc7c87f4212d5e4bb7ac65025e77c688
BLAKE2b-256 60e122180acf520df72afc951523822253c7b410e1909f5fdf745e3498283218

See more details on using hashes here.

File details

Details for the file lychrel-0.7.2-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for lychrel-0.7.2-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 e66811c47845fb44b1556bb2de578f61923083425f67afd4a2800b4337e91653
MD5 82945199027b2e37f171252302b46ca8
BLAKE2b-256 7d49fa1c3b5be06a8e26b0daeee948565e4124eeef442cbd625d088585253ad9

See more details on using hashes here.

File details

Details for the file lychrel-0.7.2-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lychrel-0.7.2-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 21c119fd2fb1d1934ab340339cb34931c5c18bcd26386f77584241b6b3708e3d
MD5 e8a47445a7ac8fc253621025bdd67b07
BLAKE2b-256 41cc874af771ea610c6ab542503b356a01ffbce9b4cc8b8ba275d6c1419477aa

See more details on using hashes here.

File details

Details for the file lychrel-0.7.2-cp37-abi3-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for lychrel-0.7.2-cp37-abi3-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 14d96eaf7445075da2509ec4638b1ae95dcf81868dc9b3fc4f4d95b847e59bf7
MD5 c05cf99b4a5964989315bd2b9b306c1a
BLAKE2b-256 676d2a7324a1b879d976f843ca4ce04855fdbf22dac18781878d15cca52d79ac

See more details on using hashes here.

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