primePy


NameprimePy JSON
Version 1.3 PyPI version JSON
download
home_pagehttps://github.com/janaindrajit/primePy
SummaryThis module contains several useful functions to work with prime numbers. from primePy import primes
upload_time2018-05-29 17:18:18
maintainer
docs_urlNone
authorIndrajit Jana
requires_python
license
keywords fast prime facorization eular phi prime check
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # primes from module primePy
This module contains several useful functions to work with prime numbers. For example, extracting all the prime factors (with multiplicity) of a positive integer reasonably fast. Following the list of all functions and their running time.

## Getting started
Download the file primes.py and place it in the same directory where your python is installed. Or, simply run the command 
```
>>>pip install primePy
```
to install the package. After installing via `pip` you can call it by 
```
>>>from primePy import primes
```
 and then execute the available methods.

## Available methods
You may run `primes.about()` afer importing the package. The following is a list of all included methods.


`primes.check(n)` returns *True* if *n* is a prime number.<br />
`primes.factor(n)` returns the lowest prime factor of *n*. <br />
`primes.facors(n)` returns all the prime factors of *n* with multiplicity.<br />
`primes.first(n)` returns first *n* many prime. <br />
`primes.upto(n)` returns all the prime less than or equal to *n*. <br />
`primes.between(m,n)` returns all the prime between *m* and *n*. <br />
`primes.phi(n)` returns the Euler's *phi(n)* i.e., the number of integers less than *n* which have no common factor with *n*. <br />


## Demonstration

This program is tested on my personal laptop with the following configurations.

>Processor: Intel(R) Core(TM) i3-4030U CPU @ 1.90Ghz<br/>
>Installed memory(RAM): 6.00GB <br/>
>System type: 64 bit Operating System, x64-based processor<br/>
>Operating system: Windows 10

### Small numbers
All the following commands returnd results in less than *1 sec*.

```
>>> primes.check(56156149)
False
>>> primes.check(79012338765433)
True
```

```
>>> primes.factor(7568945625)
3
>>> primes.factor(5141)
53
```

```
>>> primes.factors(252)
[2, 2, 3, 3, 7]
>>> primes.factors(44410608)
[2, 2, 2, 2, 3, 3, 11, 23, 23, 53]
```

```
>>> primes.first(7)
[2, 3, 5, 7, 11, 13, 17]
>>> primes.first(37)
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83,
89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157]
>>> primes.first(5000)
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83,
89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179,
. . . . 
. . . .
 48179, 48187, 48193, 48197, 48221, 48239, 48247, 48259, 48271, 48281, 48299, 48311, 48313, 48337, 48341, 48353, 48371, 48383, 48397, 48407, 48409, 48413, 48437, 48449, 48463, 48473, 48479, 48481, 48487, 48491, 48497, 48523, 48527, 48533, 48539, 48541, 48563, 48571, 48589, 48593, 48611]
```
Outcomes from the last command is truncated.

```
>>> primes.upto(16)
[2, 3, 5, 7, 11, 13]
>>> primes.upto(50000)
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83,
89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179
. . .
. . .
49789, 49801, 49807, 49811, 49823, 49831, 49843, 49853, 49871, 49877, 49891, 49919,
49921, 49927, 49937, 49939, 49943, 49957, 49991, 49993, 49999]
```

```
>>> primes.between(100,200)
[101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199]
>>> primes.between(100000,500000)
[100003, 100019, 100043, 100049, 100057, 100069, 100103, 100109, 100129, 100151, 100153,
100169, 100183, 100189, 100193, 100207, 100213, 100237, 100267, 100271, 100279, 100291

499661, 499663, 499669, 499673, 499679, 499687, 499691, 499693, 499711, 499717, 499729, 499739, 499747, 499781, 499787, 499801, 499819, 499853, 499879, 499883, 499897, 499903, 499927, 499943, 499957, 499969, 499973, 499979]
```

```
>>> primes.phi(128)
64
>>> primes.phi(561534567567457)
483618287856960
```
### A little bigger numbers

All the following commands returned results in less than *5 secs*.

```
>>> primes.factors(2910046587320501324077792713140104371205630933992706145011)
[239, 701, 709, 1997, 1997, 3889, 5171, 5171, 6983, 10009, 4940867, 45845791, 3731292319]
```

```
>>> primes.first(10000)[9999]
104729
```
The last command returns the 10000th prime.

## Suggestions
Feel free to drop your suggestion at the following email address<br/>
>Author: Indrajit Jana<br/>
>Email: ijana at temple dot edu






            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/janaindrajit/primePy",
    "name": "primePy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "fast,prime,facorization,Eular phi,prime check",
    "author": "Indrajit Jana",
    "author_email": "ijana@temple.edu",
    "download_url": "https://files.pythonhosted.org/packages/35/77/0cfa1b4697cfb5336f3a96e8bc73327f64610be3a64c97275f1801afb395/primePy-1.3.tar.gz",
    "platform": "",
    "description": "# primes from module primePy\nThis module contains several useful functions to work with prime numbers. For example, extracting all the prime factors (with multiplicity) of a positive integer reasonably fast. Following the list of all functions and their running time.\n\n## Getting started\nDownload the file primes.py and place it in the same directory where your python is installed. Or, simply run the command \n```\n>>>pip install primePy\n```\nto install the package. After installing via `pip` you can call it by \n```\n>>>from primePy import primes\n```\n and then execute the available methods.\n\n## Available methods\nYou may run `primes.about()` afer importing the package. The following is a list of all included methods.\n\n\n`primes.check(n)` returns *True* if *n* is a prime number.<br />\n`primes.factor(n)` returns the lowest prime factor of *n*. <br />\n`primes.facors(n)` returns all the prime factors of *n* with multiplicity.<br />\n`primes.first(n)` returns first *n* many prime. <br />\n`primes.upto(n)` returns all the prime less than or equal to *n*. <br />\n`primes.between(m,n)` returns all the prime between *m* and *n*. <br />\n`primes.phi(n)` returns the Euler's *phi(n)* i.e., the number of integers less than *n* which have no common factor with *n*. <br />\n\n\n## Demonstration\n\nThis program is tested on my personal laptop with the following configurations.\n\n>Processor: Intel(R) Core(TM) i3-4030U CPU @ 1.90Ghz<br/>\n>Installed memory(RAM): 6.00GB <br/>\n>System type: 64 bit Operating System, x64-based processor<br/>\n>Operating system: Windows 10\n\n### Small numbers\nAll the following commands returnd results in less than *1 sec*.\n\n```\n>>> primes.check(56156149)\nFalse\n>>> primes.check(79012338765433)\nTrue\n```\n\n```\n>>> primes.factor(7568945625)\n3\n>>> primes.factor(5141)\n53\n```\n\n```\n>>> primes.factors(252)\n[2, 2, 3, 3, 7]\n>>> primes.factors(44410608)\n[2, 2, 2, 2, 3, 3, 11, 23, 23, 53]\n```\n\n```\n>>> primes.first(7)\n[2, 3, 5, 7, 11, 13, 17]\n>>> primes.first(37)\n[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83,\n89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157]\n>>> primes.first(5000)\n[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83,\n89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179,\n. . . . \n. . . .\n 48179, 48187, 48193, 48197, 48221, 48239, 48247, 48259, 48271, 48281, 48299, 48311, 48313, 48337, 48341, 48353, 48371, 48383, 48397, 48407, 48409, 48413, 48437, 48449, 48463, 48473, 48479, 48481, 48487, 48491, 48497, 48523, 48527, 48533, 48539, 48541, 48563, 48571, 48589, 48593, 48611]\n```\nOutcomes from the last command is truncated.\n\n```\n>>> primes.upto(16)\n[2, 3, 5, 7, 11, 13]\n>>> primes.upto(50000)\n[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83,\n89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179\n. . .\n. . .\n49789, 49801, 49807, 49811, 49823, 49831, 49843, 49853, 49871, 49877, 49891, 49919,\n49921, 49927, 49937, 49939, 49943, 49957, 49991, 49993, 49999]\n```\n\n```\n>>> primes.between(100,200)\n[101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199]\n>>> primes.between(100000,500000)\n[100003, 100019, 100043, 100049, 100057, 100069, 100103, 100109, 100129, 100151, 100153,\n100169, 100183, 100189, 100193, 100207, 100213, 100237, 100267, 100271, 100279, 100291\n\n499661, 499663, 499669, 499673, 499679, 499687, 499691, 499693, 499711, 499717, 499729, 499739, 499747, 499781, 499787, 499801, 499819, 499853, 499879, 499883, 499897, 499903, 499927, 499943, 499957, 499969, 499973, 499979]\n```\n\n```\n>>> primes.phi(128)\n64\n>>> primes.phi(561534567567457)\n483618287856960\n```\n### A little bigger numbers\n\nAll the following commands returned results in less than *5 secs*.\n\n```\n>>> primes.factors(2910046587320501324077792713140104371205630933992706145011)\n[239, 701, 709, 1997, 1997, 3889, 5171, 5171, 6983, 10009, 4940867, 45845791, 3731292319]\n```\n\n```\n>>> primes.first(10000)[9999]\n104729\n```\nThe last command returns the 10000th prime.\n\n## Suggestions\nFeel free to drop your suggestion at the following email address<br/>\n>Author: Indrajit Jana<br/>\n>Email: ijana at temple dot edu\n\n\n\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "This module contains several useful functions to work with prime numbers. from primePy import primes",
    "version": "1.3",
    "split_keywords": [
        "fast",
        "prime",
        "facorization",
        "eular phi",
        "prime check"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "74c1bb7e334135859c3a92ec399bc89293ea73f28e815e35b43929c8db6af030",
                "md5": "82cce93205516dfbc290f5b4f5c850dc",
                "sha256": "5ed443718765be9bf7e2ff4c56cdff71b42140a15b39d054f9d99f0009e2317a"
            },
            "downloads": -1,
            "filename": "primePy-1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "82cce93205516dfbc290f5b4f5c850dc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4040,
            "upload_time": "2018-05-29T17:18:17",
            "upload_time_iso_8601": "2018-05-29T17:18:17.530939Z",
            "url": "https://files.pythonhosted.org/packages/74/c1/bb7e334135859c3a92ec399bc89293ea73f28e815e35b43929c8db6af030/primePy-1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "35770cfa1b4697cfb5336f3a96e8bc73327f64610be3a64c97275f1801afb395",
                "md5": "9cf3803848e4c30ec020660f81b658e2",
                "sha256": "25fd7e25344b0789a5984c75d89f054fcf1f180bef20c998e4befbac92de4669"
            },
            "downloads": -1,
            "filename": "primePy-1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "9cf3803848e4c30ec020660f81b658e2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3914,
            "upload_time": "2018-05-29T17:18:18",
            "upload_time_iso_8601": "2018-05-29T17:18:18.683163Z",
            "url": "https://files.pythonhosted.org/packages/35/77/0cfa1b4697cfb5336f3a96e8bc73327f64610be3a64c97275f1801afb395/primePy-1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2018-05-29 17:18:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "janaindrajit",
    "github_project": "primePy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "primepy"
}
        
Elapsed time: 0.09662s