pythagix 0.1.8__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 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
- count_factors,
8
+ is_prime,
9
+ is_multiple,
10
+ lcm,
11
+ middle,
12
+ nth_prime,
9
13
  triangle_number,
10
14
  )
pythagix/core.py CHANGED
@@ -1,15 +1,18 @@
1
- from math import isqrt
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
- "is_prime",
6
+ "count_factors",
7
+ "digit_sum",
8
8
  "filter_primes",
9
- "nth_prime",
10
9
  "gcd",
11
10
  "is_perfect_square",
12
- "count_factors",
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(math.gcd, values)
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.1.8
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
- **Pythagix** is a lightweight and dependency-free Python library designed for number theory operations.
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
- * `is_prime(number: int) -> bool`
38
- Determine whether a number is a prime number.
37
+ count_factors(number: int) -> List[int]
38
+ Return a sorted list of all positive factors of the given number.
39
39
 
40
- * `filter_primes(numbers: List[int]) -> List[int]`
41
- Return all prime numbers from a list of integers.
40
+ digit_sum(number: int) -> int
41
+ Return the sum of all digit in the given number.
42
42
 
43
- * `nth_prime(position: int) -> int`
44
- Retrieve the *n*-th prime number (1-based indexing).
43
+ filter_primes(numbers: List[int]) -> List[int]
44
+ Return all prime numbers from a list of integers.
45
45
 
46
- * `gcd(values: List[int]) -> int`
47
- Compute the greatest common divisor (GCD) of a list of integers.
46
+ gcd(values: List[int]) -> int
47
+ Compute the greatest common divisor (GCD) of a list of integers.
48
48
 
49
- * `is_perfect_square(number: int) -> bool`
50
- Check whether a number is a perfect square.
49
+ is_perfect_square(number: int) -> bool
50
+ Check whether a number is a perfect square.
51
51
 
52
- * `count_factors(number: int) -> List[int]`
53
- Return a sorted list of all positive factors of a number.
52
+ is_prime(number: int) -> bool
53
+ Determine whether a number is prime.
54
54
 
55
- * `triangle_number(index: int) -> int`
56
- Compute the *n*-th triangular number.
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
- * Educational platforms and math-related tools
89
+ Educational platforms and math-related tools
81
90
 
82
- * Prototyping algorithms and number-theoretic computations
91
+ Prototyping algorithms and number-theoretic computations
83
92
 
84
- * Teaching foundational concepts in discrete mathematics and number theory
93
+ Teaching foundational concepts in discrete mathematics and number theory
85
94
 
86
- * Lightweight CLI utilities and academic scripting
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,,
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) [year] [fullname]
3
+ Copyright (c) 2025 UltraQuantumScriptor
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -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,,