Skip to main content

Implements different number theory functions

Project description

Number Theory

Documentation Status codecov ci-cd

A high-performance Python package for number theory operations, optimized for Project Euler and computational mathematics problems.

Features

  • Fast prime number generation and primality testing
  • Efficient prime factorization
  • Arithmetic progression calculations
  • Optimized for computational challenges and competitive programming
  • Simple, intuitive API design

Installation

pip install num_theory

Usage

Prime Numbers

from num_theory import get_prime_list_under_n, is_prime, prime_factorization

# Generate all primes under 100
primes = get_prime_list_under_n(100)

# Check if a number is prime
is_prime(997)  # Returns True

# Get prime factorization
factors = prime_factorization(84)  # Returns [(2, 2), (3, 1), (7, 1)]

Arithmetic Progressions

from num_theory import arithmetic_progression

# Generate first 5 terms of AP with a=2, d=3
terms = arithmetic_progression(a=2, d=3, n=5)  # [2, 5, 8, 11, 14]

# Calculate sum of first 10 terms
sum_ap = arithmetic_progression(a=2, d=3, n=10, compute_sum=True)

# Find the 100th term
nth_term = arithmetic_progression(a=2, d=3, n=100, nth_term=True)

Key Functions

Function Description Example
get_prime_list_under_n(n) Generates all primes less than n get_prime_list_under_n(10) returns [2, 3, 5, 7]
prime_factorization(n) Returns prime factors with their powers prime_factorization(12) returns [(2, 2), (3, 1)]
arithmetic_progression(a, d, n, ...) Handles arithmetic progression operations See examples above
is_prime(n) Tests primality efficiently is_prime(17) returns True

Relevance in the Python Ecosystem

This package complements existing Python libraries by offering a targeted collection of number theory utilities specifically for solving Project Euler problems.

Related Packages:

  • SymPy: This does provide some symbolic mathematics, including some number theory, but isn't optimized for the computational challenges of advanced number theory.
  • NumPy: The general-purpose library for numerical computations, but not specialized in number theory.
  • primesieve: A highly efficient library for prime generation. This package provides similar functionalities.

Comparison with Other Libraries

Feature num_theory SymPy NumPy primesieve
Focus Number Theory Symbolic Math Numerical Computing Prime Generation
Optimization Project Euler General Math General Purpose Prime Numbers
Learning Curve Simple Steep Moderate Simple
Speed Fast Moderate Fast Very Fast

Contributing

Interested in contributing? Check out the contributing guidelines . Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

Authors

  • Dhruv Garg
  • Dominic Lam
  • Thamer Aldawood
  • Tingting Chen

License

num_theory was created by Dhruv Garg, Dominic Lam, Thamer Aldawood, Tingting Chen. It is licensed under the terms of the MIT license.

Credits

num_theory was created with cookiecutter and the py-pkgs-cookiecutter template.

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

num_theory_euler_problems-0.2.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

num_theory_euler_problems-0.2.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file num_theory_euler_problems-0.2.0.tar.gz.

File metadata

File hashes

Hashes for num_theory_euler_problems-0.2.0.tar.gz
Algorithm Hash digest
SHA256 fe6bc33729cece6500fe65df3b33854f4fbe07a61bebbcb797dcc3181eecdbb6
MD5 678fd14a9b11362f0b5677fcac42c2ad
BLAKE2b-256 aaee6937877aa857072f2c70a6a38497f9f7f4e8ea184330796c8983db6231f4

See more details on using hashes here.

File details

Details for the file num_theory_euler_problems-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for num_theory_euler_problems-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c5e5b6bd8f181588b0fc7367bc93c0a91fa4f02a372012da7e7cfdc503ffab0
MD5 57667bfe46543e4152548edc7b5b2f28
BLAKE2b-256 e02f8b5829696567b928967a01df9d6edb3720a2d93849e72f64efbadaacbfb8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page