Skip to main content

Pythagix is a lightweight Python library that provides a collection of mathematical utility functions for number theory

Project description

Pythagix

Pythagix is a lightweight, dependency-free Python library for number theory operations. It provides a clean and efficient interface for common mathematical utilities such as prime checking, greatest common divisor, triangular numbers, and more.

Installation You can install Pythagix using pip:

pip install pythagix

Features

compress_0(values: int | float) -> list[int | float] Clears consecutive zeros, keeping only one of the zero.

filter_primes(values: list[int]) -> list[int] Filters and returns prime numbers from a list of integers.

gcd(values: list[int]) -> int Computes the greatest common divisor (GCD) of a list of integers.

get_factors(number: int) -> List[int] Return all positive factors of a number.

is_equivalent(ratio1: tuple[int, int], ratio2: tuple[int, int]) -> bool Check if two ratios are equivalent by simplifying both and comparing.

is_prime(number: int) -> bool Checks whether a number is prime.

lcm(values: list[int]) -> int Computes the least common multiple (LCM) of a list of integers.

mean(values: list[int | float]) -> float Calculates the arithmetic mean (average) of a list of numbers.

median(values: list[int | float]) -> float Computes the median value of a list.

mode(values: list[int | float]) -> int | float | list[int | float] Computes the mode(s) of a list. Returns a single value or a list of modes.

nCr(n: int, k: int) -> Union[int, float] Count all possible k items from n.

nth_prime(position: int) -> int Retrieves the n-th prime number (1-based index).

prime_factorization(number: int) -> Union[List[int], None] Find all prime factors of the given number.

prime_factors(number: int) -> list[int] Get all prime factors of the given number.

product(values: Sequence[int | float]) -> int | float Multiplies the entire list until one number remains.

pstd_dev(values: Sequence[int | float]) -> float Determine the standard deviation of the values (population).

pvariance(values: Sequence[int | float]) -> float Work out the variance of the values (population).

simplify_ratio(ratio: tuple[int, int]) -> tuple[int, int] Simplify a ratio by dividing both terms by their greatest common divisor (GCD).

std_dev(values: list[int | float]) -> float Determine the standard deviation of the values (sample).

triangle_number(index: int) -> int Computes the n-th triangular number.

variance(values: list[int | float]) -> float Work out the variance of the values (sample).

Use Cases

Pythagix is suitable for:

Educational platforms and math-related applications

Prototyping number-theoretic algorithms

Teaching foundational concepts in discrete mathematics

Lightweight command-line tools and academic scripting

License

This project is licensed under the MIT License. You are free to use, modify, and distribute the software as permitted under the license terms.

Contributing

Contributions are welcome.

To report bugs, suggest enhancements, or submit code improvements, please open an issue or create a pull request via the GitHub repository.

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

pythagix-0.2.22.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

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

pythagix-0.2.22-cp313-cp313-win_amd64.whl (36.4 kB view details)

Uploaded CPython 3.13Windows x86-64

File details

Details for the file pythagix-0.2.22.tar.gz.

File metadata

  • Download URL: pythagix-0.2.22.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for pythagix-0.2.22.tar.gz
Algorithm Hash digest
SHA256 30c025efdf6e3678ee99a313d4f14e8957c302c5fa4d87aa3a26485dcbf68b0f
MD5 3045297378c59e8d0494797dc5fcc380
BLAKE2b-256 ad0c662244e5eeb97d20cc8dfd7a927ad867204f295f28e9211ea3296b5ba92e

See more details on using hashes here.

File details

Details for the file pythagix-0.2.22-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pythagix-0.2.22-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 36.4 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for pythagix-0.2.22-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3a5e8e77f732d14aea7ab709a1df82249eee3bf457175c9f36377f110946c32f
MD5 ba9003f0bb737e51ce70b2757707c819
BLAKE2b-256 d7864444ed0c564cb55a195b59d5e7ec4661857949868f07fe87fe89db541f01

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