Find the greatest common divisor and find integers x,y such that ax + by = gcd(a,b).
Project description
scm203lab367101691 is a lightweight Python package that provides simple utility functions
for the greatest common divisor and extended euclidean algorithm.
It is designed mainly for learning purposes and as an example of Python packaging.
Features
- gcd(a,b): This function returns the greatest common divisor of a and b using the Euclidean algorithm.
- extended_gcd(a,b): This function returns the coefficients x and y such that ax + by = gcd(a, b).
Installation
You can install the package directly from PyPI:
pip install scm203lab367101691
Example1 (gcd(a,b))
-Input
import scm203lab367101691 as scm
a = 234
b = 42
d=scm.gcd(a,b)
print(f"The gcd of 234 and 42 is {d}")
-Output
234 = 5*42 + 24
42 = 1*24 + 18
24 = 1*18 + 6
18 = 3*6
The gcd of 234 and 42 is 6
Example2 (extended_gcd(a,b))
-Input
import scm203lab367101691 as scm
a = 7920
b = 4536
print(scm.extended_gcd(a,b))
-Output
72 = 72*1 + 1080*0
72 = 1080*-1 + 1152*1
72 = 1152*3 + 3384*-1
72 = 3384*-4 + 4536*3
72 = 4536*7 + 7920*-4
72 = 1080*-1 + 1152*1
72 = 1152*3 + 3384*-1
72 = 3384*-4 + 4536*3
72 = 1080*-1 + 1152*1
72 = 1152*3 + 3384*-1
72 = 1080*-1 + 1152*1
72 = 1080*-1 + 1152*1
72 = 1080*-1 + 1152*1
72 = 1152*3 + 3384*-1
72 = 3384*-4 + 4536*3
72 = 3384*-4 + 4536*3
72 = 4536*7 + 7920*-4
72 = 7920*-4 + 4536*7
(72, -4, 7) #gcd(a,b) = 72,x = -4,y = 7
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scm203lab367101691-0.1.0.tar.gz.
File metadata
- Download URL: scm203lab367101691-0.1.0.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a630aaf8a3939c11b261c6fab041cfc602204395ed7e82f8245cdf73c4804d32
|
|
| MD5 |
8f5ef58c9632340190c407b761e1de28
|
|
| BLAKE2b-256 |
25b45e36a392c10bcf11a9569475b13e757747510c83d82982c6c3b1b74b3744
|
File details
Details for the file scm203lab367101691-0.1.0-py3-none-any.whl.
File metadata
- Download URL: scm203lab367101691-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
554d2b5452aa4477a0432b002193080b982caf7a9ccfa4471a2e7c7276faadd9
|
|
| MD5 |
8fc40edc6196a4394be7bd77fe6188ff
|
|
| BLAKE2b-256 |
4c7628a0abf34dff09157ba8b4857d03bfba5052b45107828ef1a28fe30e9aaa
|