This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

eulerlib is a library of recreational mathematics and number theory related functions inspired by Project Euler. Available functions include:

  • Prime number generation
  • Divisor functions (sigma functions)
  • Euler’s totient function
  • Greatest Common Divisor (GCD) using Euclid’s algorithm
  • Least Common Multiple (LCM)
  • Integer square root
  • Fibonacci numbers
  • Pandigital numbers
  • Palindrome numbers
  • Pythagorean triples

Functions from this library can be used to solve recreational mathematics and programming problems such as problems in Project Euler.

Installation

eulerlib is avalaible through Python Package Index (PyPI) using pip.

>>> pip install --upgrade eulerlib

To uninstall using pip.

>>> pip uninstall eulerlib

Usage

In Python console you can import functions/classes from eulerlib as needed.

>>> from eulerlib import primes
>>> p10 = primes(10)
>>> print(p10)
[2, 3, 5, 7]

The Divisors class implements functions related to prime factorization, sigma functions etc.

>>> from eulerlib import Divisors
>>> mydiv = Divisors(10000)
>>> div84 = mydiv.divisors(84) #divisors of 84
>>> print(div84)
[1, 2, 3, 4, 6, 7, 12, 14, 21, 28, 42, 84]
>>> pf840 = mydiv.prime_factors(840) # prime factors of 840
>>> print(pf840)
[(2, 3), (3, 1), (5, 1), (7, 1)]

Example: Solved Project Euler problem 3.

from eulerlib import is_square, primes
#get approximate square root of number since
#largest prime factor < sq. root
(is_sq, sqroot) = is_square(600851475143L)
#get a list of primes less than the approx. square root.
test_primes = primes(sqroot + 1L)
#test the primes from the list to find the largest factor
len_p = len(test_primes)
for i in range(1,len_p+1):
    j = 0 - i
    test_fact = test_primes[j]
    if 600851475143L%test_fact == 0:
        break
answer = test_fact #Set the answer

See complete documentation.

Modules

prime_numbers.py Functions to generate lists of primes.
numtheory.py
  • Euler’s divisor functions (sigma funtions)
  • Euler’s totient function (phi function)
  • Prime factors of a number
  • Divisors of a number
  • Greatest Common Divisor (GCD)
  • Least Common Multiple (LCM)
  • Digital root and digital sum of a number
fibonacci.py Functions related to the Fibonacci sequence.
pythagoras.py Functions related to Pythagorean triples.
etc.py

Miscellaneous functions:

  • Pandigital numbers
  • Conversion from decimal to base n (2-36)
  • Number to lists and vice versa
  • Palindrome numbers

Development

Source code repositories (GitHub, BitBucket) are available. Bug reports and suggestions are most welcome.

License

eulerlib is licensed under Apache License 2.0.

Release History

Release History

0.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
eulerlib-0.2.zip (24.3 kB) Copy SHA256 Checksum SHA256 Source May 5, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting