Skip to main content

An demonstration of how to implement Gaussian Integer operations in Python.

Project description

It is easy to take the unique factorization property for granted, but with more experience we will see that this gift is not something which had to happen. Among the similar “integers” that are dealt with in the advanced topics of number theory there are examples with unique factorization (for example the Gaussian integers, Z[i]) and conversely there are examples where unique factorization fails (for example Z[√-5], where the otherwise perfectly well behaved integer 6 has as prime factorizations both 6 = (2)(3) and a second one 6 = (-1)(1+√-5)(1-√-5)).

The package PyKhana contains a method implemented entirely in Python3. It can be used to implement Gaussian Integer Numbers.

Gaussian Integer functions. Functions implemented are: Arithmetic functions: +,*,//,%,**(exponentiation) a.gcd(b) - Compute the greatest common divisor of a and b. a.xgcd(b) - Extended gcd - return gcd(a,b) and x,y such that gcd(a,b)=xa+yb. n.isprime() - Is n prime (pseudoprime tests) n.factor() - Return a factor of n. n.factors() - Return list of the factors of n. Gaussian Integers can be created by: n = GaussInt(5,7) # Create (5 + 7i) n = GaussInt(13) # Create (5 + 0i) z = complex(2,3); n = GaussInt(z) # Round the complex number to integer form

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyKhana-0.0.3.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

PyKhana-0.0.3-py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page