Skip to main content

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

Project description

Lychrel

PyPI version

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.

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].

Project details


Download files

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

Files for lychrel, version 0.4.0
Filename, size File type Python version Upload date Hashes
Filename, size lychrel-0.4.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl (201.1 kB) File type Wheel Python version cp310 Upload date Hashes View
Filename, size lychrel-0.4.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (198.6 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size lychrel-0.4.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (201.0 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size lychrel-0.4.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (369.1 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size lychrel-0.4.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (201.0 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size lychrel-0.4.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (369.1 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size lychrel-0.4.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (201.1 kB) File type Wheel Python version cp39 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page