pymathfuncts 0.1.1__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.
- pymathfuncts-0.1.1/LICENSE +21 -0
- pymathfuncts-0.1.1/PKG-INFO +11 -0
- pymathfuncts-0.1.1/README.md +1 -0
- pymathfuncts-0.1.1/pymathfuncts/__init__.py +1 -0
- pymathfuncts-0.1.1/pymathfuncts/core.py +120 -0
- pymathfuncts-0.1.1/pymathfuncts.egg-info/PKG-INFO +11 -0
- pymathfuncts-0.1.1/pymathfuncts.egg-info/SOURCES.txt +9 -0
- pymathfuncts-0.1.1/pymathfuncts.egg-info/dependency_links.txt +1 -0
- pymathfuncts-0.1.1/pymathfuncts.egg-info/top_level.txt +1 -0
- pymathfuncts-0.1.1/pyproject.toml +11 -0
- pymathfuncts-0.1.1/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 m1ss-j4zz
|
|
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.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# pymathfuncts
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .core import *
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Factorial - fac(n)
|
|
2
|
+
def fac(n):
|
|
3
|
+
if n == 1:
|
|
4
|
+
return 1
|
|
5
|
+
if n == 2:
|
|
6
|
+
return 2
|
|
7
|
+
else:
|
|
8
|
+
return n * (fac(n - 1))
|
|
9
|
+
|
|
10
|
+
# Fibonnaci - fib(n)
|
|
11
|
+
def fib(n):
|
|
12
|
+
if n == 0:
|
|
13
|
+
return 0
|
|
14
|
+
if n == 1:
|
|
15
|
+
return 1
|
|
16
|
+
else:
|
|
17
|
+
n1, n2 = 0, 1
|
|
18
|
+
for num in range(2, n + 1):
|
|
19
|
+
n1, n2 = n2, n1 + n2
|
|
20
|
+
return n2
|
|
21
|
+
|
|
22
|
+
# Triangular Number - tri(n)
|
|
23
|
+
def tri(n):
|
|
24
|
+
n1 = n + 1
|
|
25
|
+
n2 = n * n1
|
|
26
|
+
return n2 // 2
|
|
27
|
+
|
|
28
|
+
# Exponate - exp(n)
|
|
29
|
+
def exp(n, e):
|
|
30
|
+
return n ** e
|
|
31
|
+
|
|
32
|
+
# Collatz Sequence - cc(n)
|
|
33
|
+
def cc(n):
|
|
34
|
+
steps = 0
|
|
35
|
+
while n > 1:
|
|
36
|
+
if n % 2 == 0:
|
|
37
|
+
n = n // 2
|
|
38
|
+
else:
|
|
39
|
+
n = (3 * n) + 1
|
|
40
|
+
steps += 1
|
|
41
|
+
return steps
|
|
42
|
+
|
|
43
|
+
# Even or Odd - eo(n)
|
|
44
|
+
def eo(n):
|
|
45
|
+
if n % 2 == 0:
|
|
46
|
+
return "Even"
|
|
47
|
+
else:
|
|
48
|
+
return "Odd"
|
|
49
|
+
|
|
50
|
+
# Greatest Common Diviser - gcd(n, b)
|
|
51
|
+
def gcd(n, b):
|
|
52
|
+
n, b = abs(n), abs(b)
|
|
53
|
+
while b > 0:
|
|
54
|
+
n, b = b, n % b
|
|
55
|
+
return n
|
|
56
|
+
|
|
57
|
+
# Least Common Multiple - lcm(n, b)
|
|
58
|
+
def lcm(n, b):
|
|
59
|
+
top = abs(n * b)
|
|
60
|
+
bottom = gcd(n, b)
|
|
61
|
+
return top // bottom
|
|
62
|
+
|
|
63
|
+
# Comprime? - copm(n, p)
|
|
64
|
+
def copm(n, b):
|
|
65
|
+
if gcd(n, b) == 1:
|
|
66
|
+
return True
|
|
67
|
+
else:
|
|
68
|
+
return False
|
|
69
|
+
|
|
70
|
+
# N Choose R - ncr(n, b)
|
|
71
|
+
def ncr(n, b):
|
|
72
|
+
top = fac(n)
|
|
73
|
+
bottom = fac(b) * fac((n - b))
|
|
74
|
+
return top // bottom
|
|
75
|
+
|
|
76
|
+
# Area of Rectangle - ar(b, h)
|
|
77
|
+
def ar(b, h):
|
|
78
|
+
return b * h
|
|
79
|
+
|
|
80
|
+
# Area of Triangle - at(b, h)
|
|
81
|
+
def at(b, h):
|
|
82
|
+
return 0.5 * b * h
|
|
83
|
+
|
|
84
|
+
# Area of Circle - ac(r)
|
|
85
|
+
def ac(r):
|
|
86
|
+
return 0.5 * r * 3.141592653589793
|
|
87
|
+
|
|
88
|
+
# Nth Term - nthgeo(x, y, n) and nthari(x, y, n)
|
|
89
|
+
def nthgeo(x, y, n):
|
|
90
|
+
r = y / x
|
|
91
|
+
return x * (r ** (n - 1))
|
|
92
|
+
|
|
93
|
+
def nthari(x, y, n):
|
|
94
|
+
d = y - x
|
|
95
|
+
return x + d * (n - 1)
|
|
96
|
+
|
|
97
|
+
# Sum of Geometric Sequence - sumgeo(x, y, z) and sumgeoN(x, y, z, n)
|
|
98
|
+
def sumgeo(x, y, z):
|
|
99
|
+
if y // x == z // y:
|
|
100
|
+
r = y / x
|
|
101
|
+
if abs(r) < 1:
|
|
102
|
+
return x / (1 - r)
|
|
103
|
+
else:
|
|
104
|
+
return "series diverges"
|
|
105
|
+
else:
|
|
106
|
+
return "not a geometric sequence"
|
|
107
|
+
|
|
108
|
+
def sumgeoN(x, y, z, n):
|
|
109
|
+
if y // x == z // y:
|
|
110
|
+
r = y / x
|
|
111
|
+
return x * ((1 - r ** n) / 1 - r)
|
|
112
|
+
else:
|
|
113
|
+
return "not a geometric sequence"
|
|
114
|
+
|
|
115
|
+
# Sum of Arithmetic Sequence - sumariN(x, y, z, n)
|
|
116
|
+
def sumariN(x, y, z, n):
|
|
117
|
+
if abs((z - y) - (y - x)) <= 0.0000000001:
|
|
118
|
+
return (n / 2) * (x + nthari(x, y, n))
|
|
119
|
+
else:
|
|
120
|
+
return "not an arithmetic sequence"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pymathfuncts
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pymathfuncts"
|
|
3
|
+
version = "0.1.1"
|
|
4
|
+
description = "Math Functions Not In Base Python"
|
|
5
|
+
authors = [{ name = "Jaz"}]
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
requires-python = ">=3.8"
|
|
8
|
+
|
|
9
|
+
[build-system]
|
|
10
|
+
requires = ["setuptools"]
|
|
11
|
+
build-backend = "setuptools.build_meta"
|