eulerlib
所属分类:数学计算
开发工具:Python
文件大小:30KB
下载次数:0
上传日期:2015-05-05 22:23:55
上 传 者:
sh-1993
说明: 受欧拉计划启发的娱乐数学和数论相关函数库
(A library of recreational mathematics and number theory related functions inspired by Project Euler)
文件列表:
LICENSE.txt (11558, 2015-05-06)
MANIFEST.in (30, 2015-05-06)
docs (0, 2015-05-06)
docs\Makefile (6770, 2015-05-06)
docs\conf.py (10621, 2015-05-06)
docs\eulerlib.rst (868, 2015-05-06)
docs\index.rst (521, 2015-05-06)
docs\make.bat (6705, 2015-05-06)
docs\modules.rst (61, 2015-05-06)
eulerlib (0, 2015-05-06)
eulerlib\__init__.py (962, 2015-05-06)
eulerlib\_exceptions.py (1035, 2015-05-06)
eulerlib\_tests (0, 2015-05-06)
eulerlib\_tests\__init__.py (662, 2015-05-06)
eulerlib\_tests\test_eulerlib.py (5869, 2015-05-06)
eulerlib\etc.py (9950, 2015-05-06)
eulerlib\fibonacci.py (3424, 2015-05-06)
eulerlib\numtheory.py (12633, 2015-05-06)
eulerlib\prime_numbers.py (5942, 2015-05-06)
eulerlib\pythagoras.py (2265, 2015-05-06)
setup.py (1809, 2015-05-06)
EulerLib
********
`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`_.
.. _Project Euler: https://projecteuler.net
.. _PyPI: https://pypi.python.org/pypi
.. _pip: https://pip.pypa.io
.. _Apache License 2.0: https://www.apache.org/licenses/LICENSE-2.0.html
.. _problem 3: https://projecteuler.net/problem=3
.. _GitHub: https://github.com/transmogrifier/eulerlib
.. _BitBucket: https://bitbucket.org/transmogrifier/eulerlib
.. _Bug reports: https://github.com/transmogrifier/eulerlib/issues
.. _documentation: http://pythonhosted.org/eulerlib
.. _eulerlib1: https://pypi.python.org/pypi/eulerlib
__ eulerlib1_
__ eulerlib1_
近期下载者:
相关文件:
收藏者: