pythagix 0.1.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.0/LICENSE +21 -0
- pythagix-0.1.0/MANIFEST.in +2 -0
- pythagix-0.1.0/PKG-INFO +16 -0
- pythagix-0.1.0/README.md +0 -0
- pythagix-0.1.0/pythagix/__init__.py +10 -0
- pythagix-0.1.0/pythagix/core.py +144 -0
- pythagix-0.1.0/pythagix.egg-info/PKG-INFO +16 -0
- pythagix-0.1.0/pythagix.egg-info/SOURCES.txt +10 -0
- pythagix-0.1.0/pythagix.egg-info/dependency_links.txt +1 -0
- pythagix-0.1.0/pythagix.egg-info/top_level.txt +1 -0
- pythagix-0.1.0/setup.cfg +4 -0
- pythagix-0.1.0/setup.py +16 -0
pythagix-0.1.0/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) [year] [fullname]
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
pythagix-0.1.0/PKG-INFO
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: pythagix
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: A mathy Python package with utilities like LCM, triangle numbers, etc.
|
5
|
+
Author: Your Name
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
8
|
+
Requires-Python: >=3.6
|
9
|
+
Description-Content-Type: text/markdown
|
10
|
+
License-File: LICENSE
|
11
|
+
Dynamic: author
|
12
|
+
Dynamic: classifier
|
13
|
+
Dynamic: description-content-type
|
14
|
+
Dynamic: license-file
|
15
|
+
Dynamic: requires-python
|
16
|
+
Dynamic: summary
|
pythagix-0.1.0/README.md
ADDED
File without changes
|
@@ -0,0 +1,144 @@
|
|
1
|
+
def prime_list(number_list: list[int]) -> list[int]:
|
2
|
+
"""
|
3
|
+
Returns a list of all prime numbers from a given list.
|
4
|
+
|
5
|
+
Args:
|
6
|
+
number_list (list[int]): The list of integers to check.
|
7
|
+
|
8
|
+
Returns:
|
9
|
+
list[int]: A list containing only the prime numbers from the input.
|
10
|
+
"""
|
11
|
+
prime_number: list[int] = []
|
12
|
+
for x in number_list:
|
13
|
+
if x == 1:
|
14
|
+
continue
|
15
|
+
for y in range(2, int(x * 1 / 2 + 1)):
|
16
|
+
if x % y == 0:
|
17
|
+
break
|
18
|
+
else:
|
19
|
+
prime_number.append(x)
|
20
|
+
return prime_number
|
21
|
+
|
22
|
+
|
23
|
+
def is_prime(number: int) -> bool:
|
24
|
+
"""
|
25
|
+
Checks whether a number is a prime number.
|
26
|
+
|
27
|
+
Args:
|
28
|
+
number (int): The number to check.
|
29
|
+
|
30
|
+
Returns:
|
31
|
+
bool: True if the number is prime, False otherwise.
|
32
|
+
"""
|
33
|
+
for y in range(2, int(number * 1 / 2)):
|
34
|
+
if number % y == 0:
|
35
|
+
return False
|
36
|
+
else:
|
37
|
+
return True
|
38
|
+
|
39
|
+
|
40
|
+
def nth_prime(index: int) -> int:
|
41
|
+
"""
|
42
|
+
Returns the n-th prime number (1-indexed).
|
43
|
+
|
44
|
+
Args:
|
45
|
+
index (int): The position of the prime to find.
|
46
|
+
|
47
|
+
Returns:
|
48
|
+
int: The n-th prime number.
|
49
|
+
|
50
|
+
Raises:
|
51
|
+
ValueError: If index is less than 1.
|
52
|
+
"""
|
53
|
+
if index < 1:
|
54
|
+
raise ValueError("Index must be >= 1")
|
55
|
+
|
56
|
+
count: int = 0
|
57
|
+
prime_number: int = 2
|
58
|
+
while True:
|
59
|
+
if is_prime(prime_number):
|
60
|
+
count += 1
|
61
|
+
if count == index:
|
62
|
+
return prime_number
|
63
|
+
prime_number += 1
|
64
|
+
|
65
|
+
|
66
|
+
def gcd(number_list: list[int]) -> int:
|
67
|
+
"""
|
68
|
+
Returns the greatest common divisor (GCD) of a list of integers.
|
69
|
+
|
70
|
+
Args:
|
71
|
+
number_list (list[int]): The list of integers.
|
72
|
+
|
73
|
+
Returns:
|
74
|
+
int: The greatest number that divides all elements in the list.
|
75
|
+
"""
|
76
|
+
num: int = 2
|
77
|
+
highest: int = 0
|
78
|
+
while num <= min(number_list):
|
79
|
+
for number in number_list:
|
80
|
+
if number % num != 0:
|
81
|
+
break
|
82
|
+
else:
|
83
|
+
highest = num
|
84
|
+
num += 1
|
85
|
+
return highest
|
86
|
+
|
87
|
+
|
88
|
+
def is_perfect_square(number: int) -> bool:
|
89
|
+
"""
|
90
|
+
Checks whether a number is a perfect square.
|
91
|
+
|
92
|
+
Args:
|
93
|
+
number (int): The number to check.
|
94
|
+
|
95
|
+
Returns:
|
96
|
+
bool: True if the number is a perfect square, False otherwise.
|
97
|
+
"""
|
98
|
+
num: int = 0
|
99
|
+
while num <= number:
|
100
|
+
if num**2 == number:
|
101
|
+
return True
|
102
|
+
num += 1
|
103
|
+
return False
|
104
|
+
|
105
|
+
|
106
|
+
def count_factors(number: int) -> list[int]:
|
107
|
+
"""
|
108
|
+
Returns a list of all factors (divisors) of a number.
|
109
|
+
|
110
|
+
Args:
|
111
|
+
number (int): The number to find factors of.
|
112
|
+
|
113
|
+
Returns:
|
114
|
+
list[int]: A list of all positive integers that divide the number evenly.
|
115
|
+
"""
|
116
|
+
num: int = 1
|
117
|
+
factors: list[int] = []
|
118
|
+
while num <= number:
|
119
|
+
if number % num == 0:
|
120
|
+
factors.append(num)
|
121
|
+
num += 1
|
122
|
+
return factors
|
123
|
+
|
124
|
+
|
125
|
+
def triangle_number(number: int) -> int:
|
126
|
+
"""
|
127
|
+
Returns the n-th triangle number.
|
128
|
+
|
129
|
+
Args:
|
130
|
+
number (int): The term (n) of the triangle number sequence.
|
131
|
+
|
132
|
+
Returns:
|
133
|
+
int: The n-th triangle number, calculated as n(n+1)//2.
|
134
|
+
"""
|
135
|
+
return number * (number + 1) // 2
|
136
|
+
|
137
|
+
|
138
|
+
if __name__ == "__main__":
|
139
|
+
|
140
|
+
def main():
|
141
|
+
"""Runs a quick test of any function."""
|
142
|
+
print(triangle_number(10))
|
143
|
+
|
144
|
+
main()
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: pythagix
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: A mathy Python package with utilities like LCM, triangle numbers, etc.
|
5
|
+
Author: Your Name
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
8
|
+
Requires-Python: >=3.6
|
9
|
+
Description-Content-Type: text/markdown
|
10
|
+
License-File: LICENSE
|
11
|
+
Dynamic: author
|
12
|
+
Dynamic: classifier
|
13
|
+
Dynamic: description-content-type
|
14
|
+
Dynamic: license-file
|
15
|
+
Dynamic: requires-python
|
16
|
+
Dynamic: summary
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
pythagix
|
pythagix-0.1.0/setup.cfg
ADDED
pythagix-0.1.0/setup.py
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
from setuptools import setup, find_packages
|
2
|
+
|
3
|
+
setup(
|
4
|
+
name="pythagix",
|
5
|
+
version="0.1.0",
|
6
|
+
author="Your Name",
|
7
|
+
description="A mathy Python package with utilities like LCM, triangle numbers, etc.",
|
8
|
+
long_description=open("README.md").read(),
|
9
|
+
long_description_content_type="text/markdown",
|
10
|
+
packages=find_packages(),
|
11
|
+
classifiers=[
|
12
|
+
"Programming Language :: Python :: 3",
|
13
|
+
"License :: OSI Approved :: MIT License",
|
14
|
+
],
|
15
|
+
python_requires=">=3.6",
|
16
|
+
)
|