Skip to main content

Fully factors given integer: unique prime factorization

Project description

UpfPy

This package includes a function, factor(); it takes an integer and returns a list.

This list represents the Unique Prime Factorization of a given integer.

The values of the list indices are such that the nth index contains the power on the nth prime in the Unique Prime Factorization of the given integer so that 2=[1], 3=[0,1] and 12=[2,1] and so fourth; the list terminates when the rest of the subsequent values are all zero.

These lists are stored in a file called vectors.txt as csv. The reason I made this is partly to generate that file. Next we will be adding a number of basic functions to analyze that file which is really a model of the prime factor structure inside integers; and also I want to make it faster and make it reflect other aspects of prime numbers such as all primes greater than 3 are either 1 or 5 modulo 6.

Installation

Run the following to install:

pip install -i https://test.pypi.org/simple/ upfpy

Usage

The first time upfpy is imported it will create a file, vectors.txt; from here on out will refer to the lists produced by factor() as vectors. The inital file contains four rows.

The first row will be a csv list of primes and the initial file will just have a 2 here. When factor() is given a number, say N, greater than 2, all the primes less than N will appended here after a comma; it will append N if N is prime. The subsequent rows are vectors, i.e., unique prime factor lists.

The second row will contain an empty bracket [ ], this represents the integer zero and is the "null" or "empty" vector.

The third row represents the number one and contains a '0'. Consider:

1 = (2**0)*(3**0)*(5**0)*(7**0)...(n**0)... = [0,0,0,0,...] = [0]; where n is the nth prime

which is not true in python but it's true in math and we are modeling this structure using python.

The forth row represents the integer 2 and contains a '1'; because...

2 = (2**1)*(3**0)*(5**0)... = [1,0,0,...] = [1]

...python
>>> from upfpy import *
>>> factor(30)
[1,1,1]

There is one class, UFD() in upf and it has two subclasses Generate() and Show(); I will relocate and change this. Generate() is used to calculate vectors that arent already in vectors.txt and writes them to there as needed.

If you exectued factor(30) as earlier you could execute:

>>> UFD().primes
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]

also note:

>>> UFD().vectors[1:6]
[[0], [1], [0, 1], [2], [0, 0, 1]]

and:

>>> UFD().show()
0 []
1 [0]
2 [1]
3 [0, 1]
4 [2]
5 [0, 0, 1]
...
28 [2, 0, 0, 1]
29 [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
30 [1, 1, 1]

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

upfpy-0.0.5.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

upfpy-0.0.5-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file upfpy-0.0.5.tar.gz.

File metadata

  • Download URL: upfpy-0.0.5.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.1

File hashes

Hashes for upfpy-0.0.5.tar.gz
Algorithm Hash digest
SHA256 6fff7b8b078d950a963b49a1215a8179809a43daf0a0a5a07ed04df778c27213
MD5 82eb3a213e883afc77e1b3fea2cd6d73
BLAKE2b-256 da8fdbb0032afcae8064c58628845c20cb112bd49be790ec0240404de715f40a

See more details on using hashes here.

File details

Details for the file upfpy-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: upfpy-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.1

File hashes

Hashes for upfpy-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a0b31ce736fd3d33641166e079b07883efa4f00a4874a560af1edffad98bb7d9
MD5 87b231011efb6b769d4a84aea68dc43a
BLAKE2b-256 6c328031ac3617c90e0b6a4f280bd82d7452b498ba0497c12b18ddb9694d4b9a

See more details on using hashes here.

Supported by

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