pythagix 0.1.8__py3-none-any.whl → 0.1.9__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/core.py +29 -7
- {pythagix-0.1.8.dist-info → pythagix-0.1.9.dist-info}/METADATA +1 -1
- pythagix-0.1.9.dist-info/RECORD +7 -0
- {pythagix-0.1.8.dist-info → pythagix-0.1.9.dist-info}/licenses/LICENSE +1 -1
- pythagix-0.1.8.dist-info/RECORD +0 -7
- {pythagix-0.1.8.dist-info → pythagix-0.1.9.dist-info}/WHEEL +0 -0
- {pythagix-0.1.8.dist-info → pythagix-0.1.9.dist-info}/top_level.txt +0 -0
pythagix/core.py
CHANGED
@@ -1,7 +1,6 @@
|
|
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
|
"is_prime",
|
@@ -30,7 +29,7 @@ def is_prime(number: int) -> bool:
|
|
30
29
|
return True
|
31
30
|
if number % 2 == 0:
|
32
31
|
return False
|
33
|
-
for i in range(3, isqrt(number) + 1, 2):
|
32
|
+
for i in range(3, m.isqrt(number) + 1, 2):
|
34
33
|
if number % i == 0:
|
35
34
|
return False
|
36
35
|
return True
|
@@ -90,7 +89,7 @@ def gcd(values: List[int]) -> int:
|
|
90
89
|
"""
|
91
90
|
if not values:
|
92
91
|
raise ValueError("Input list must not be empty")
|
93
|
-
return reduce(
|
92
|
+
return reduce(m.gcd, values)
|
94
93
|
|
95
94
|
|
96
95
|
def is_perfect_square(number: int) -> bool:
|
@@ -105,7 +104,7 @@ def is_perfect_square(number: int) -> bool:
|
|
105
104
|
"""
|
106
105
|
if number < 0:
|
107
106
|
return False
|
108
|
-
root = isqrt(number)
|
107
|
+
root = m.isqrt(number)
|
109
108
|
return root * root == number
|
110
109
|
|
111
110
|
|
@@ -126,7 +125,7 @@ def count_factors(number: int) -> List[int]:
|
|
126
125
|
raise ValueError("Number must be positive")
|
127
126
|
|
128
127
|
factors = set()
|
129
|
-
for i in range(1, isqrt(number) + 1):
|
128
|
+
for i in range(1, m.isqrt(number) + 1):
|
130
129
|
if number % i == 0:
|
131
130
|
factors.add(i)
|
132
131
|
factors.add(number // i)
|
@@ -151,9 +150,32 @@ def triangle_number(index: int) -> int:
|
|
151
150
|
return index * (index + 1) // 2
|
152
151
|
|
153
152
|
|
153
|
+
def lcm(values: List[int]) -> int:
|
154
|
+
"""
|
155
|
+
Compute the least common multiple (LCM) of a list of integers.
|
156
|
+
|
157
|
+
Args:
|
158
|
+
values (List[int]): A list of integers.
|
159
|
+
|
160
|
+
Returns:
|
161
|
+
int: The LCM of the numbers.
|
162
|
+
|
163
|
+
Raises:
|
164
|
+
ValueError: If the list is empty.
|
165
|
+
"""
|
166
|
+
if not values:
|
167
|
+
raise ValueError("Input list must not empty")
|
168
|
+
|
169
|
+
result = 0
|
170
|
+
i1, i2 = 0, 1
|
171
|
+
for v in values:
|
172
|
+
if v
|
173
|
+
|
174
|
+
|
175
|
+
|
154
176
|
def main() -> None:
|
155
177
|
"""Tester Function."""
|
156
|
-
|
178
|
+
print(lcm([2, 4, 6]))
|
157
179
|
|
158
180
|
|
159
181
|
if __name__ == "__main__":
|
@@ -0,0 +1,7 @@
|
|
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,,
|
pythagix-0.1.8.dist-info/RECORD
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
pythagix/__init__.py,sha256=6tpiGil3VFdLrZ9fUZ41YY7qAkNyWOC74fiUNCuXzAE,175
|
2
|
-
pythagix/core.py,sha256=-zmDFcEsfqL8G-cEY8CCfw1YA0_fDnRrLv4g-bxeews,3534
|
3
|
-
pythagix-0.1.8.dist-info/licenses/LICENSE,sha256=Qv2ilebwoUtMJnRsZwRy729xS5JZQzLauJ0tQzkAkTA,1088
|
4
|
-
pythagix-0.1.8.dist-info/METADATA,sha256=9PwgsSy98be7P03BuTsAXC0jES0pufTSQ2kQxTU2JQU,2669
|
5
|
-
pythagix-0.1.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
-
pythagix-0.1.8.dist-info/top_level.txt,sha256=U3rm-YGObQkL0gSuVWFPZTakILlqyAd7pUVvtJiMlsE,9
|
7
|
-
pythagix-0.1.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|