Skip to main content

A mathy Python package with utilities like LCM, triangle numbers, etc.

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

count_factors(number: int) -> int Returns the number of all positive divisors of the number.

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

digit_sum(number: int) -> int Returns the sum of all digits in the given number.

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

from_percentage(number: int | float) -> float Convert a percentage to a decimal.

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_perfect_square(number: int) -> bool Determines whether a number is a perfect square.

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

is_multiple(number: int, base: int) -> bool Checks if one number is a multiple of another.

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.

middle(a: int | float, b: int | float) -> float Returns the midpoint of two numeric values.

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.

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

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

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[float]) -> float Determine the standard deviation of the values

to_percentage(number: int | float) -> int | float Convert a decimal to a percentage.

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

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

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.18.tar.gz (7.9 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.18-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pythagix-0.2.18.tar.gz
  • Upload date:
  • Size: 7.9 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.18.tar.gz
Algorithm Hash digest
SHA256 b2d087ad1039ac856d746418dfd6c2976d0060782212b384eec7abbe5a4ebf25
MD5 d298bf8459b1fea4d7373b082db804cc
BLAKE2b-256 4306872020fee82138a84abb3da40b3e28e5fb1d1e871ba6f25a267647e86b7c

See more details on using hashes here.

File details

Details for the file pythagix-0.2.18-py3-none-any.whl.

File metadata

  • Download URL: pythagix-0.2.18-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for pythagix-0.2.18-py3-none-any.whl
Algorithm Hash digest
SHA256 c74b5e97dfac69daacf132baa83880a4f9f746df9a48e25509d36544e21a067f
MD5 1a855fce83280b13f2d042536e5efb21
BLAKE2b-256 ed3779507e89c1abea3ca3471a50148d36b0e4a053502a66bdcd1f2f0ee11df9

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