pythagix 0.1.9__py3-none-any.whl → 0.2.0__py3-none-any.whl
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/__init__.py +7 -3
- pythagix/core.py +52 -8
- {pythagix-0.1.9.dist-info → pythagix-0.2.0.dist-info}/METADATA +29 -20
- pythagix-0.2.0.dist-info/RECORD +7 -0
- pythagix-0.1.9.dist-info/RECORD +0 -7
- {pythagix-0.1.9.dist-info → pythagix-0.2.0.dist-info}/WHEEL +0 -0
- {pythagix-0.1.9.dist-info → pythagix-0.2.0.dist-info}/licenses/LICENSE +0 -0
- {pythagix-0.1.9.dist-info → pythagix-0.2.0.dist-info}/top_level.txt +0 -0
pythagix/__init__.py
CHANGED
@@ -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
|
)
|
pythagix/core.py
CHANGED
@@ -3,12 +3,16 @@ from functools import reduce
|
|
3
3
|
from typing import List
|
4
4
|
|
5
5
|
__all__ = [
|
6
|
-
"
|
6
|
+
"count_factors",
|
7
|
+
"digit_sum",
|
7
8
|
"filter_primes",
|
8
|
-
"nth_prime",
|
9
9
|
"gcd",
|
10
10
|
"is_perfect_square",
|
11
|
-
"
|
11
|
+
"is_prime",
|
12
|
+
"is_multiple",
|
13
|
+
"lcm",
|
14
|
+
"middle",
|
15
|
+
"nth_prime",
|
12
16
|
"triangle_number",
|
13
17
|
]
|
14
18
|
|
@@ -166,16 +170,56 @@ def lcm(values: List[int]) -> int:
|
|
166
170
|
if not values:
|
167
171
|
raise ValueError("Input list must not empty")
|
168
172
|
|
169
|
-
|
170
|
-
|
171
|
-
|
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
|
+
"""
|
173
216
|
|
217
|
+
return (a + b) / 2
|
174
218
|
|
175
219
|
|
176
220
|
def main() -> None:
|
177
221
|
"""Tester Function."""
|
178
|
-
print(
|
222
|
+
print(middle(246, 2))
|
179
223
|
|
180
224
|
|
181
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
|
|
@@ -0,0 +1,7 @@
|
|
1
|
+
pythagix/__init__.py,sha256=LUVDAw14_IqsBFgs0qWQor9QNQ3VlDG9XSH-ONMT7xY,232
|
2
|
+
pythagix/core.py,sha256=dyLRvIJbH5RABSTEK3ZuF0BrVjdbVRFrn6RTs0PmkgA,4963
|
3
|
+
pythagix-0.2.0.dist-info/licenses/LICENSE,sha256=mAiqjt0kIJZfw70XUmdIrsvPwnhKBMerHN3nDFg8H9c,1096
|
4
|
+
pythagix-0.2.0.dist-info/METADATA,sha256=3EqjE5mGCx53YX_4NNcKZL2UgpX9lR-pBAuNbO2mfGU,2875
|
5
|
+
pythagix-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
+
pythagix-0.2.0.dist-info/top_level.txt,sha256=U3rm-YGObQkL0gSuVWFPZTakILlqyAd7pUVvtJiMlsE,9
|
7
|
+
pythagix-0.2.0.dist-info/RECORD,,
|
pythagix-0.1.9.dist-info/RECORD
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
pythagix/__init__.py,sha256=6tpiGil3VFdLrZ9fUZ41YY7qAkNyWOC74fiUNCuXzAE,175
|
2
|
-
pythagix/core.py,sha256=IfshQbq1v-m5WXf4T3tfCW1usfVu_f9jlqjgoHNqelA,3986
|
3
|
-
pythagix-0.1.9.dist-info/licenses/LICENSE,sha256=mAiqjt0kIJZfw70XUmdIrsvPwnhKBMerHN3nDFg8H9c,1096
|
4
|
-
pythagix-0.1.9.dist-info/METADATA,sha256=6sGeTrPAXqOkbWHn0nOR8raWAlyM2e3nxSrzzUBYLT0,2669
|
5
|
-
pythagix-0.1.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
-
pythagix-0.1.9.dist-info/top_level.txt,sha256=U3rm-YGObQkL0gSuVWFPZTakILlqyAd7pUVvtJiMlsE,9
|
7
|
-
pythagix-0.1.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|