Skip to main content

A Python library with mathematical utilities: primality testing, factorization, sequence generation, boolean logic, and coordinate geometry.

Project description

HyqerionMath

PyPI version Python versions License: MIT

A Python library providing supplementary mathematical utility functions, focusing on number theory, sequences, geometry, and competitive programming algorithms.

Overview

HyqerionMath aims to offer helpful, well-tested math functions that extend Python's built-in math module. It is designed to be simple, efficient, and easy to use—making it a perfect companion for math competitions, algorithmic challenges, and general programming.

Features

HyqerionMath includes:

Primality Functions (primality.py)

  • isprime(number: int) -> bool: Efficiently checks if a given integer number is a prime number. Returns True if prime, False otherwise.
  • get_nth_prime(n: int) -> int: Finds the n-th prime number (1-based index). e.g., get_nth_prime(5) is 11.
  • get_primes_in_index_range(start_index: int, end_index: int) -> List[int]: Returns a list containing primes from the start_index-th prime to the end_index-th prime (inclusive, 1-based).
  • find_primes_between(lower_bound: int, upper_bound: int) -> List[int]: Returns a sorted list of all prime numbers p such that lower_bound <= p <= upper_bound.

Factorization Functions (factorization.py)

  • get_factors(number: int) -> List[int]: Finds all positive integer factors of a given number. e.g., get_factors(12) returns [1, 2, 3, 4, 6, 12].
  • get_proper_divisors(number: int) -> List[int]: Finds all positive factors of a number EXCEPT the number itself.
  • sum_proper_divisors(number: int) -> int: Returns the sum of all proper divisors.
  • are_amicable(a: int, b: int) -> bool: Checks if two numbers form an amicable pair.
  • get_prime_factorization(number: int) -> List[int]: Returns a sorted list of the prime factors of number (including duplicates). e.g., get_prime_factorization(20) returns [2, 2, 5].

Sequence Functions (sequences.py)

  • get_nth_fibonacci(n: int) -> int: Calculates the n-th Fibonacci number using 1-based indexing (F(1)=0, F(2)=1, F(3)=1...).
  • fibonacci_mod(n: int, mod: int) -> int: Efficiently calculates the n-th Fibonacci number modulo mod without memory overflow.
  • get_fibonacci_in_index_range(start_index: int, end_index: int) -> List[int]: Returns a list of Fibonacci numbers within a specific index range.
  • get_nth_triangular(n: int) -> int: Returns the n-th triangular number n(n+1)/2.
  • get_lazy_caterer(n: int) -> int: Returns the maximum number of pieces a circle can be cut into with n straight cuts (n^2 + n + 2)/2.

Digit & Base Functions (digits.py)

  • get_digits(number: int, base: int = 10) -> list: Returns a list of the digits of a number in a specific base.
  • is_armstrong(number: int) -> bool: Checks if a number is an Armstrong (Narcissistic) number.
  • base_to_base10(string_val: str, base: int) -> int: Converts a string representation of a number in any base (2-36) to Base 10.
  • get_champernowne_digit(n: int) -> int: Efficiently finds the n-th digit of the Champernowne constant sequence (123456789101112...) in O(1) mathematical time.

Geometry Functions (geometry.py)

  • generate_pythagorean_triples(limit: int) -> List[Tuple[int, int, int]]: Generates all Pythagorean triples (a, b, c) where the hypotenuse c <= limit.
  • lattice_points_in_circle(radius_squared: int) -> int: Counts the number of integer coordinates (x, y) that fall strictly inside a circle of a given squared radius.
  • circles_intersect(x1, y1, r1, x2, y2, r2) -> str: Evaluates the intersection of two circles. Returns 'CAUGHT' (overlap), 'DANGER' (tangent), or 'SAFE' (separated).

Boolean Logic (logic.py)

  • evaluate_truth_table(variables: list, expression: str) -> list: Generates a complete truth table for a given boolean expression string.
  • count_true_statements(variables: list, expression: str) -> int: Counts how many permutations of the given variables evaluate to True.

(More features may be added in the future!)

Installation

You can install HyqerionMath directly from PyPI:

pip install hyqerionmath

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

hyqerionmath-0.5.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

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

hyqerionmath-0.5.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file hyqerionmath-0.5.0.tar.gz.

File metadata

  • Download URL: hyqerionmath-0.5.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for hyqerionmath-0.5.0.tar.gz
Algorithm Hash digest
SHA256 bb8ba8f89294fd04747d4d44b10af4baf469767216341c2905e71d91c828e1ce
MD5 8d013f031fd7ac4c2fcd3c6bd2458bac
BLAKE2b-256 c081e7e24a27cbb42614a309340c3b2703b61663f134178e2db38efd5a38ad70

See more details on using hashes here.

File details

Details for the file hyqerionmath-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: hyqerionmath-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for hyqerionmath-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 45e78815e1a8bd1af4e891624e7cd36198d29caac1f93491b998fbb765139013
MD5 b7bbb13160d20c1c509d0a4c5505685c
BLAKE2b-256 8de7f30582c778ad8438a1a58e103ec7fc16ed0b29437fe086a1f96fd3de91f3

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