pythagix 0.1.8__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pythagix-0.1.8 → pythagix-0.2.0}/LICENSE +1 -1
- {pythagix-0.1.8/pythagix.egg-info → pythagix-0.2.0}/PKG-INFO +29 -20
- pythagix-0.2.0/README.md +97 -0
- {pythagix-0.1.8 → pythagix-0.2.0}/pyproject.toml +1 -1
- {pythagix-0.1.8 → pythagix-0.2.0}/pythagix/__init__.py +7 -3
- {pythagix-0.1.8 → pythagix-0.2.0}/pythagix/core.py +76 -10
- {pythagix-0.1.8 → pythagix-0.2.0/pythagix.egg-info}/PKG-INFO +29 -20
- {pythagix-0.1.8 → pythagix-0.2.0}/setup.py +1 -1
- pythagix-0.1.8/README.md +0 -88
- {pythagix-0.1.8 → pythagix-0.2.0}/MANIFEST.in +0 -0
- {pythagix-0.1.8 → pythagix-0.2.0}/pythagix.egg-info/SOURCES.txt +0 -0
- {pythagix-0.1.8 → pythagix-0.2.0}/pythagix.egg-info/dependency_links.txt +0 -0
- {pythagix-0.1.8 → pythagix-0.2.0}/pythagix.egg-info/top_level.txt +0 -0
- {pythagix-0.1.8 → pythagix-0.2.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: pythagix
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.2.0
|
4
4
|
Summary: A mathy Python package with utilities like LCM, triangle numbers, etc.
|
5
5
|
Author: UltraQuantumScriptor
|
6
6
|
License: MIT
|
@@ -17,7 +17,7 @@ Dynamic: requires-python
|
|
17
17
|
|
18
18
|
# Pythagix
|
19
19
|
|
20
|
-
|
20
|
+
Pythagix is a lightweight and dependency-free Python library designed for number theory operations.
|
21
21
|
It provides a clean, efficient interface to common mathematical utilities such as prime number checks, greatest common divisor computation, triangular numbers, and more.
|
22
22
|
|
23
23
|
---
|
@@ -34,26 +34,35 @@ pip install pythagix
|
|
34
34
|
|
35
35
|
## Features
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
count_factors(number: int) -> List[int]
|
38
|
+
Return a sorted list of all positive factors of the given number.
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
digit_sum(number: int) -> int
|
41
|
+
Return the sum of all digit in the given number.
|
42
42
|
|
43
|
-
|
44
|
-
|
43
|
+
filter_primes(numbers: List[int]) -> List[int]
|
44
|
+
Return all prime numbers from a list of integers.
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
gcd(values: List[int]) -> int
|
47
|
+
Compute the greatest common divisor (GCD) of a list of integers.
|
48
48
|
|
49
|
-
|
50
|
-
|
49
|
+
is_perfect_square(number: int) -> bool
|
50
|
+
Check whether a number is a perfect square.
|
51
51
|
|
52
|
-
|
53
|
-
|
52
|
+
is_prime(number: int) -> bool
|
53
|
+
Determine whether a number is prime.
|
54
54
|
|
55
|
-
|
56
|
-
|
55
|
+
lcm(values: List[int]) -> int
|
56
|
+
Compute the least common multiple (LCM) of a list of integers.
|
57
|
+
|
58
|
+
middle(a: int | float, b: int | float) -> float
|
59
|
+
Return the midpoint of two numbers.
|
60
|
+
|
61
|
+
nth_prime(position: int) -> int
|
62
|
+
Retrieve the n-th prime number (1-based index).
|
63
|
+
|
64
|
+
triangle_number(index: int) -> int
|
65
|
+
Compute the n-th triangular number.
|
57
66
|
|
58
67
|
---
|
59
68
|
|
@@ -77,13 +86,13 @@ print(triangle_number(7)) # Output: 28
|
|
77
86
|
|
78
87
|
Pythagix is ideal for:
|
79
88
|
|
80
|
-
|
89
|
+
Educational platforms and math-related tools
|
81
90
|
|
82
|
-
|
91
|
+
Prototyping algorithms and number-theoretic computations
|
83
92
|
|
84
|
-
|
93
|
+
Teaching foundational concepts in discrete mathematics and number theory
|
85
94
|
|
86
|
-
|
95
|
+
Lightweight CLI utilities and academic scripting
|
87
96
|
|
88
97
|
---
|
89
98
|
|
pythagix-0.2.0/README.md
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
---
|
2
|
+
|
3
|
+
# Pythagix
|
4
|
+
|
5
|
+
Pythagix is a lightweight and dependency-free Python library designed for number theory operations.
|
6
|
+
It provides a clean, efficient interface to common mathematical utilities such as prime number checks, greatest common divisor computation, triangular numbers, and more.
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Install Pythagix using pip:
|
13
|
+
|
14
|
+
```bash
|
15
|
+
pip install pythagix
|
16
|
+
```
|
17
|
+
|
18
|
+
---
|
19
|
+
|
20
|
+
## Features
|
21
|
+
|
22
|
+
count_factors(number: int) -> List[int]
|
23
|
+
Return a sorted list of all positive factors of the given number.
|
24
|
+
|
25
|
+
digit_sum(number: int) -> int
|
26
|
+
Return the sum of all digit in the given number.
|
27
|
+
|
28
|
+
filter_primes(numbers: List[int]) -> List[int]
|
29
|
+
Return all prime numbers from a list of integers.
|
30
|
+
|
31
|
+
gcd(values: List[int]) -> int
|
32
|
+
Compute the greatest common divisor (GCD) of a list of integers.
|
33
|
+
|
34
|
+
is_perfect_square(number: int) -> bool
|
35
|
+
Check whether a number is a perfect square.
|
36
|
+
|
37
|
+
is_prime(number: int) -> bool
|
38
|
+
Determine whether a number is prime.
|
39
|
+
|
40
|
+
lcm(values: List[int]) -> int
|
41
|
+
Compute the least common multiple (LCM) of a list of integers.
|
42
|
+
|
43
|
+
middle(a: int | float, b: int | float) -> float
|
44
|
+
Return the midpoint of two numbers.
|
45
|
+
|
46
|
+
nth_prime(position: int) -> int
|
47
|
+
Retrieve the n-th prime number (1-based index).
|
48
|
+
|
49
|
+
triangle_number(index: int) -> int
|
50
|
+
Compute the n-th triangular number.
|
51
|
+
|
52
|
+
---
|
53
|
+
|
54
|
+
## Example Usage
|
55
|
+
|
56
|
+
```python
|
57
|
+
from pythagix import is_prime, nth_prime, gcd, triangle_number
|
58
|
+
|
59
|
+
print(is_prime(13)) # Output: True
|
60
|
+
|
61
|
+
print(nth_prime(10)) # Output: 29
|
62
|
+
|
63
|
+
print(gcd([12, 18, 24])) # Output: 6
|
64
|
+
|
65
|
+
print(triangle_number(7)) # Output: 28
|
66
|
+
```
|
67
|
+
|
68
|
+
---
|
69
|
+
|
70
|
+
## Use Cases
|
71
|
+
|
72
|
+
Pythagix is ideal for:
|
73
|
+
|
74
|
+
Educational platforms and math-related tools
|
75
|
+
|
76
|
+
Prototyping algorithms and number-theoretic computations
|
77
|
+
|
78
|
+
Teaching foundational concepts in discrete mathematics and number theory
|
79
|
+
|
80
|
+
Lightweight CLI utilities and academic scripting
|
81
|
+
|
82
|
+
---
|
83
|
+
|
84
|
+
## License
|
85
|
+
|
86
|
+
Pythagix is released under the [MIT License](LICENSE), making it free to use, modify, and distribute.
|
87
|
+
|
88
|
+
---
|
89
|
+
|
90
|
+
## Contributing
|
91
|
+
|
92
|
+
Contributions are welcome!
|
93
|
+
If you'd like to add features, report bugs, or improve documentation, please open an issue or submit a pull request on the [GitHub repository](https://github.com/your-username/pythagix).
|
94
|
+
|
95
|
+
---
|
96
|
+
|
97
|
+
If you want me to tailor this even more (e.g. add badges, GitHub Actions, versioning, or PyPI metadata snippets), I can assist with that too.
|
@@ -1,10 +1,14 @@
|
|
1
1
|
# pythagix/__init__.py
|
2
2
|
from .core import (
|
3
|
+
count_factors,
|
4
|
+
digit_sum,
|
3
5
|
filter_primes,
|
4
|
-
is_prime,
|
5
|
-
nth_prime,
|
6
6
|
gcd,
|
7
7
|
is_perfect_square,
|
8
|
-
|
8
|
+
is_prime,
|
9
|
+
is_multiple,
|
10
|
+
lcm,
|
11
|
+
middle,
|
12
|
+
nth_prime,
|
9
13
|
triangle_number,
|
10
14
|
)
|
@@ -1,15 +1,18 @@
|
|
1
|
-
|
1
|
+
import math as m
|
2
2
|
from functools import reduce
|
3
3
|
from typing import List
|
4
|
-
import math
|
5
4
|
|
6
5
|
__all__ = [
|
7
|
-
"
|
6
|
+
"count_factors",
|
7
|
+
"digit_sum",
|
8
8
|
"filter_primes",
|
9
|
-
"nth_prime",
|
10
9
|
"gcd",
|
11
10
|
"is_perfect_square",
|
12
|
-
"
|
11
|
+
"is_prime",
|
12
|
+
"is_multiple",
|
13
|
+
"lcm",
|
14
|
+
"middle",
|
15
|
+
"nth_prime",
|
13
16
|
"triangle_number",
|
14
17
|
]
|
15
18
|
|
@@ -30,7 +33,7 @@ def is_prime(number: int) -> bool:
|
|
30
33
|
return True
|
31
34
|
if number % 2 == 0:
|
32
35
|
return False
|
33
|
-
for i in range(3, isqrt(number) + 1, 2):
|
36
|
+
for i in range(3, m.isqrt(number) + 1, 2):
|
34
37
|
if number % i == 0:
|
35
38
|
return False
|
36
39
|
return True
|
@@ -90,7 +93,7 @@ def gcd(values: List[int]) -> int:
|
|
90
93
|
"""
|
91
94
|
if not values:
|
92
95
|
raise ValueError("Input list must not be empty")
|
93
|
-
return reduce(
|
96
|
+
return reduce(m.gcd, values)
|
94
97
|
|
95
98
|
|
96
99
|
def is_perfect_square(number: int) -> bool:
|
@@ -105,7 +108,7 @@ def is_perfect_square(number: int) -> bool:
|
|
105
108
|
"""
|
106
109
|
if number < 0:
|
107
110
|
return False
|
108
|
-
root = isqrt(number)
|
111
|
+
root = m.isqrt(number)
|
109
112
|
return root * root == number
|
110
113
|
|
111
114
|
|
@@ -126,7 +129,7 @@ def count_factors(number: int) -> List[int]:
|
|
126
129
|
raise ValueError("Number must be positive")
|
127
130
|
|
128
131
|
factors = set()
|
129
|
-
for i in range(1, isqrt(number) + 1):
|
132
|
+
for i in range(1, m.isqrt(number) + 1):
|
130
133
|
if number % i == 0:
|
131
134
|
factors.add(i)
|
132
135
|
factors.add(number // i)
|
@@ -151,9 +154,72 @@ def triangle_number(index: int) -> int:
|
|
151
154
|
return index * (index + 1) // 2
|
152
155
|
|
153
156
|
|
157
|
+
def lcm(values: List[int]) -> int:
|
158
|
+
"""
|
159
|
+
Compute the least common multiple (LCM) of a list of integers.
|
160
|
+
|
161
|
+
Args:
|
162
|
+
values (List[int]): A list of integers.
|
163
|
+
|
164
|
+
Returns:
|
165
|
+
int: The LCM of the numbers.
|
166
|
+
|
167
|
+
Raises:
|
168
|
+
ValueError: If the list is empty.
|
169
|
+
"""
|
170
|
+
if not values:
|
171
|
+
raise ValueError("Input list must not empty")
|
172
|
+
|
173
|
+
return reduce(m.lcm, values)
|
174
|
+
|
175
|
+
|
176
|
+
def digit_sum(number: int) -> int:
|
177
|
+
"""
|
178
|
+
Sum all digits that are in the given number
|
179
|
+
|
180
|
+
Args:
|
181
|
+
number (int): The number whose digits are to be summed.
|
182
|
+
|
183
|
+
Returns:
|
184
|
+
int: The sum of the digits in the number
|
185
|
+
"""
|
186
|
+
|
187
|
+
return sum([int(digit) for digit in str(number)])
|
188
|
+
|
189
|
+
|
190
|
+
def is_multiple(number: int, base: int) -> bool:
|
191
|
+
"""
|
192
|
+
Check if a number is a multiple of another number.
|
193
|
+
|
194
|
+
Args:
|
195
|
+
n (int): The number to test.
|
196
|
+
base (int): The base to check against.
|
197
|
+
|
198
|
+
Returns:
|
199
|
+
bool: True if n is a multiple of base, False otherwise.
|
200
|
+
"""
|
201
|
+
|
202
|
+
return number % base == 0
|
203
|
+
|
204
|
+
|
205
|
+
def middle(a: int | float, b: int | float) -> float:
|
206
|
+
"""
|
207
|
+
Return the midpoint between two numbers.
|
208
|
+
|
209
|
+
Args:
|
210
|
+
a (float): The first number.
|
211
|
+
b (float): The second number.
|
212
|
+
|
213
|
+
Returns:
|
214
|
+
float: The average of the two numbers.
|
215
|
+
"""
|
216
|
+
|
217
|
+
return (a + b) / 2
|
218
|
+
|
219
|
+
|
154
220
|
def main() -> None:
|
155
221
|
"""Tester Function."""
|
156
|
-
|
222
|
+
print(middle(246, 2))
|
157
223
|
|
158
224
|
|
159
225
|
if __name__ == "__main__":
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: pythagix
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.2.0
|
4
4
|
Summary: A mathy Python package with utilities like LCM, triangle numbers, etc.
|
5
5
|
Author: UltraQuantumScriptor
|
6
6
|
License: MIT
|
@@ -17,7 +17,7 @@ Dynamic: requires-python
|
|
17
17
|
|
18
18
|
# Pythagix
|
19
19
|
|
20
|
-
|
20
|
+
Pythagix is a lightweight and dependency-free Python library designed for number theory operations.
|
21
21
|
It provides a clean, efficient interface to common mathematical utilities such as prime number checks, greatest common divisor computation, triangular numbers, and more.
|
22
22
|
|
23
23
|
---
|
@@ -34,26 +34,35 @@ pip install pythagix
|
|
34
34
|
|
35
35
|
## Features
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
count_factors(number: int) -> List[int]
|
38
|
+
Return a sorted list of all positive factors of the given number.
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
digit_sum(number: int) -> int
|
41
|
+
Return the sum of all digit in the given number.
|
42
42
|
|
43
|
-
|
44
|
-
|
43
|
+
filter_primes(numbers: List[int]) -> List[int]
|
44
|
+
Return all prime numbers from a list of integers.
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
gcd(values: List[int]) -> int
|
47
|
+
Compute the greatest common divisor (GCD) of a list of integers.
|
48
48
|
|
49
|
-
|
50
|
-
|
49
|
+
is_perfect_square(number: int) -> bool
|
50
|
+
Check whether a number is a perfect square.
|
51
51
|
|
52
|
-
|
53
|
-
|
52
|
+
is_prime(number: int) -> bool
|
53
|
+
Determine whether a number is prime.
|
54
54
|
|
55
|
-
|
56
|
-
|
55
|
+
lcm(values: List[int]) -> int
|
56
|
+
Compute the least common multiple (LCM) of a list of integers.
|
57
|
+
|
58
|
+
middle(a: int | float, b: int | float) -> float
|
59
|
+
Return the midpoint of two numbers.
|
60
|
+
|
61
|
+
nth_prime(position: int) -> int
|
62
|
+
Retrieve the n-th prime number (1-based index).
|
63
|
+
|
64
|
+
triangle_number(index: int) -> int
|
65
|
+
Compute the n-th triangular number.
|
57
66
|
|
58
67
|
---
|
59
68
|
|
@@ -77,13 +86,13 @@ print(triangle_number(7)) # Output: 28
|
|
77
86
|
|
78
87
|
Pythagix is ideal for:
|
79
88
|
|
80
|
-
|
89
|
+
Educational platforms and math-related tools
|
81
90
|
|
82
|
-
|
91
|
+
Prototyping algorithms and number-theoretic computations
|
83
92
|
|
84
|
-
|
93
|
+
Teaching foundational concepts in discrete mathematics and number theory
|
85
94
|
|
86
|
-
|
95
|
+
Lightweight CLI utilities and academic scripting
|
87
96
|
|
88
97
|
---
|
89
98
|
|
@@ -6,7 +6,7 @@ with open("README.md", encoding="utf-8") as f:
|
|
6
6
|
|
7
7
|
setup(
|
8
8
|
name="pythagix",
|
9
|
-
version="0.
|
9
|
+
version="0.2.0",
|
10
10
|
author="UltraQuantumScriptor",
|
11
11
|
description="A mathy Python package with utilities like LCM, triangle numbers, etc.",
|
12
12
|
long_description=long_description,
|
pythagix-0.1.8/README.md
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
---
|
2
|
-
|
3
|
-
# Pythagix
|
4
|
-
|
5
|
-
**Pythagix** is a lightweight and dependency-free Python library designed for number theory operations.
|
6
|
-
It provides a clean, efficient interface to common mathematical utilities such as prime number checks, greatest common divisor computation, triangular numbers, and more.
|
7
|
-
|
8
|
-
---
|
9
|
-
|
10
|
-
## Installation
|
11
|
-
|
12
|
-
Install Pythagix using pip:
|
13
|
-
|
14
|
-
```bash
|
15
|
-
pip install pythagix
|
16
|
-
```
|
17
|
-
|
18
|
-
---
|
19
|
-
|
20
|
-
## Features
|
21
|
-
|
22
|
-
* `is_prime(number: int) -> bool`
|
23
|
-
Determine whether a number is a prime number.
|
24
|
-
|
25
|
-
* `filter_primes(numbers: List[int]) -> List[int]`
|
26
|
-
Return all prime numbers from a list of integers.
|
27
|
-
|
28
|
-
* `nth_prime(position: int) -> int`
|
29
|
-
Retrieve the *n*-th prime number (1-based indexing).
|
30
|
-
|
31
|
-
* `gcd(values: List[int]) -> int`
|
32
|
-
Compute the greatest common divisor (GCD) of a list of integers.
|
33
|
-
|
34
|
-
* `is_perfect_square(number: int) -> bool`
|
35
|
-
Check whether a number is a perfect square.
|
36
|
-
|
37
|
-
* `count_factors(number: int) -> List[int]`
|
38
|
-
Return a sorted list of all positive factors of a number.
|
39
|
-
|
40
|
-
* `triangle_number(index: int) -> int`
|
41
|
-
Compute the *n*-th triangular number.
|
42
|
-
|
43
|
-
---
|
44
|
-
|
45
|
-
## Example Usage
|
46
|
-
|
47
|
-
```python
|
48
|
-
from pythagix import is_prime, nth_prime, gcd, triangle_number
|
49
|
-
|
50
|
-
print(is_prime(13)) # Output: True
|
51
|
-
|
52
|
-
print(nth_prime(10)) # Output: 29
|
53
|
-
|
54
|
-
print(gcd([12, 18, 24])) # Output: 6
|
55
|
-
|
56
|
-
print(triangle_number(7)) # Output: 28
|
57
|
-
```
|
58
|
-
|
59
|
-
---
|
60
|
-
|
61
|
-
## Use Cases
|
62
|
-
|
63
|
-
Pythagix is ideal for:
|
64
|
-
|
65
|
-
* Educational platforms and math-related tools
|
66
|
-
|
67
|
-
* Prototyping algorithms and number-theoretic computations
|
68
|
-
|
69
|
-
* Teaching foundational concepts in discrete mathematics and number theory
|
70
|
-
|
71
|
-
* Lightweight CLI utilities and academic scripting
|
72
|
-
|
73
|
-
---
|
74
|
-
|
75
|
-
## License
|
76
|
-
|
77
|
-
Pythagix is released under the [MIT License](LICENSE), making it free to use, modify, and distribute.
|
78
|
-
|
79
|
-
---
|
80
|
-
|
81
|
-
## Contributing
|
82
|
-
|
83
|
-
Contributions are welcome!
|
84
|
-
If you'd like to add features, report bugs, or improve documentation, please open an issue or submit a pull request on the [GitHub repository](https://github.com/your-username/pythagix).
|
85
|
-
|
86
|
-
---
|
87
|
-
|
88
|
-
If you want me to tailor this even more (e.g. add badges, GitHub Actions, versioning, or PyPI metadata snippets), I can assist with that too.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|