# Working With Primes
This Python module provides a collection of functions for visualizing and performing operations with prime numbers. It is a simple tool for mathematical analysis and educational purposes.
## Usage
To use this module, import it in your Python script:
to import all functions
```
from wwp import *
```
or to import specific functions,
```
from wwp import _function_name_
```
Then you can use the functions provided in the module, For example:<br>
Getting the first 5 known prime numbers:
```
from wwp import firstNPrimes
firstFivePrimes = firstNPrimes(5)
print(firstTwelvePrimes)
#Output: [2, 3, 5, 7, 11]
```
## Functions
### firstNPrimes(n):
Returns an array containing the first 'n' prime numbers along the number line.<br><br>
**Arguments**:<br>
n (int): The number of prime numbers to generate.<br><br>
**Returns**:<br>
list: A list of the first 'n' prime numbers. <br>
None: If 'n' is equal to 0.
### isPrime(n):
Returns True if 'n' is prime and False if it is not.<br><br>
**Arguments**:<br>
n (int): The number to check for primality.<br><br>
**Returns**:<br>
Boolean: True if 'n' is prime and False if it is not.<br>
None: If 'n' is equal to 0.
### differences(n):
Returns an array containing the differences between successive prime numbers up to the 'n'-th prime.<br><br>
**Arguments**:<br>
n (int): The number of prime numbers to consider for difference calculation.<br><br>
**Returns**:<br>
list: A list of the differences between successive prime numbers.<br>
None: If 'n' is equal to 0.
### sumOfPrimes(n):
Calculates the sum of the first 'n' prime numbers.<br><br>
**Arguments**:<br>
n (int): The first 'n' prime numbers to add up.<br><br>
**Returns**:<br>
int: The sum of the first n prime numbers.<br>
None: If 'n' is equal to 0.
### theNthPrime(n):
Returns the 'n'-th prime number.<br><br>
**Arguments**:<br>
n (int): The position of the prime number.<br><br>
**Returns**:<br>
int: The 'n'-th prime number.<br>
None: If 'n' is equal to 0.
### sumOfDifferences(n):
Calculates the sum of differences between the first 'n' prime numbers.<br><br>
**Arguments**:<br>
n (int): The first 'n' prime numbers to consider.<br><br>
**Returns**:<br>
int: The sum of the differences between the first 'n' prime numbers.<br>
None: If 'n' is equal to 0.
### primeCounting(n):
Returns the number of primes less than 'n'.<br><br>
**Arguments**:<br>
n (int): The positive integer for which you want to count the prime numbers less than it.<br><br>
**Returns**:<br>
int: The number of prime numbers less than 'n'.<br>
None: If 'n' is equal to 0.
### lcm(n):
Calculates the lowest common multiple of the first 'n' primes.<br><br>
**Arguments**:<br>
n (int): The first 'n' prime numbers to consider.<br><br>
**Returns**:<br>
int: The lowest common multiple of the first 'n' prime numbers<br>
None: If 'n' is equal to 0.
### primeSlice(start, stop):
Returns an array of prime numbers between 'start' and 'stop' (inclusive).<br><br>
**Arguments**:<br>
start (int): The starting integer for the range.<br>
stop (int): The ending integer for the range.<br><br>
**Returns**:<br>
list: A list of prime numbers within the inclusive range from 'start' to 'stop'.
### primeDifferenceSlice(start, stop):
Returns an array of the differences between successive prime numbers between 'start' and 'stop' (inclusive).<br><br>
**Arguments**:<br>
start (int): The starting integer for the range.<br>
stop (int): The ending integer for the range.<br><br>
**Returns**:<br>
list: A list of the differences between the prime numbers within the inclusive range from 'start' to 'stop'.
### modifyValues(array, operation, operand):
Modifies an array using the specified 'operation' and 'operand' values.<br><br>
**Arguments**:<br>
array (arr): An array of integer values.<br>
operation (str): The operation to perform on the prime numbers within the range. Valid values are "multiply" or "*", "divide" or "/", "subtract" or "-", "add" or "+", and "exponent" or "^".<br>
operand (int, float or expression): The value to use as the operand for the specified operation.<br><br>
**Returns**:<br>
list: A list of integers after applying the specified 'operation' and 'operand'.
### randomPrimeSlice(start, stop, length):
Generates a random selection of prime numbers within the inclusive range from 'start' to 'stop'.<br><br>
**Arguments**:<br>
start (int): The starting integer for the range.<br>
stop (int): The ending integer for the range.<br>
length (int): The number of prime numbers to include in the random selection.<br><br>
**Returns**:<br>
list: A list of prime numbers randomly selected from within the inclusive range between 'start' and 'stop'.<br>
None: 'length' is equal to 0.
### randomDifferencesSlice(start, stop, length):
Generates a random selection of differences between successive prime numbers within the inclusive range from 'start' to 'stop'.<br><br>
**Arguments**:<br>
start (int): The starting integer for the range.<br>
stop (int): The ending integer for the range.<br>
length (int): The number of differences to include in the random range.<br><br>
**Returns**:<br>
list: A list of the differences between prime numbers randomly selected from within the inclusive range between 'start' and 'stop'.<br>
None: 'length' is equal to 0.
### graphDifferences(n):
Graphs the differences between the first 'n' successive prime numbers.<br><br>
**Arguments**:<br>
n (int): The number of successive prime numbers to consider for generating the graph.<br><br>
**Returns**:<br>
This function doesn't return any value; it generates and displays a graph.<br>
None: if 'n' is equal to 0.
### graphPrimes(stop, operation, operand, start):
Plots and displays a graph comparing a set of regular and modified prime numbers.<br><br>
**Arguments**:<br>
stop (int): The ending integer for the range of primes.<br>
operation (str, optional): The mathematical operation to apply to the prime numbers. Valid values are "multiply" or "*", "divide" or "/", "subtract" or "-", "add" or "+", and "exponent" or "^". Defaults to addition ("+").<br>
operand (int, float, or expression, optional): The value to use as the operand for the specified operation. Defaults to 0.<br>
start (int, optional): The starting integer for the range. Defaults to 1.<br><br>
**Returns**:<br>
This function doesn't return any value; it generates and displays a graph.
### sacksSpiral(n, coordinateRange, dotSize):
Draws a Sacks Spiral representation of the first 'n' prime numbers.<br><br>
**Arguments**:<br>
n (int): The first 'n' prime numbers to consider for drawing the Sacks Spiral.<br>
coordinateRange (int, optional): The coordinate system's range for both axis. Defaults to 100.<br>
dotSize (int, optional): The size of dots representing the prime numbers. Defaults to 5.<br><br>
**Returns**:<br>
This function doesn't return any value; it generates and displays a drawing.
### differenceSpiral(n, coordinateRange, dotSize):
Draws a spiral using the same rules of the Sacks Spiral using non-repeating differences
between the primes instead of the primes themselves. Uses turtle graphics library.<br><br>
**Arguments**:<br>
n (int): The limit of differences to consider for drawing the spiral.<br>
coordinateRange (int, optional): The coordinate system's range for both axis. Defaults to 15.<br>
dotSize (int, optional): The size of dots representing the differences. Defaults to 10.<br><br>
**Returns**:<br>
This function doesn't return any value; it generates and displays a graph.
## License
This project is licensed under the MIT License - see the [LICENSE](https://mit-license.org/) for more details.
Raw data
{
"_id": null,
"home_page": "https://github.com/Langton49/workingWithPrimes",
"name": "wwp",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "Prime,Numbers,Mathematics,Math",
"author": "Munashe",
"author_email": "munashemukweya2022@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/72/ca/fdafd0763076a5dce966629234eb4913dcfa1ef33a0be78bc36e02fd568c/wwp-1.1.1.tar.gz",
"platform": null,
"description": "# Working With Primes\r\n\r\nThis Python module provides a collection of functions for visualizing and performing operations with prime numbers. It is a simple tool for mathematical analysis and educational purposes.\r\n\r\n## Usage\r\n\r\nTo use this module, import it in your Python script:\r\n\r\nto import all functions\r\n\r\n```\r\nfrom wwp import *\r\n```\r\n\r\nor to import specific functions,\r\n\r\n```\r\nfrom wwp import _function_name_\r\n```\r\n\r\nThen you can use the functions provided in the module, For example:<br>\r\n\r\n\r\nGetting the first 5 known prime numbers:\r\n\r\n```\r\nfrom wwp import firstNPrimes\r\n\r\nfirstFivePrimes = firstNPrimes(5)\r\n\r\nprint(firstTwelvePrimes)\r\n\r\n#Output: [2, 3, 5, 7, 11] \r\n```\r\n\r\n## Functions\r\n\r\n### firstNPrimes(n): \r\nReturns an array containing the first 'n' prime numbers along the number line.<br><br>\r\n**Arguments**:<br>\r\nn (int): The number of prime numbers to generate.<br><br>\r\n**Returns**:<br>\r\nlist: A list of the first 'n' prime numbers. <br>\r\nNone: If 'n' is equal to 0.\r\n\r\n### isPrime(n):\r\nReturns True if 'n' is prime and False if it is not.<br><br>\r\n**Arguments**:<br>\r\nn (int): The number to check for primality.<br><br>\r\n**Returns**:<br>\r\nBoolean: True if 'n' is prime and False if it is not.<br>\r\nNone: If 'n' is equal to 0.\r\n\r\n### differences(n):\r\nReturns an array containing the differences between successive prime numbers up to the 'n'-th prime.<br><br>\r\n**Arguments**:<br>\r\nn (int): The number of prime numbers to consider for difference calculation.<br><br>\r\n**Returns**:<br>\r\nlist: A list of the differences between successive prime numbers.<br>\r\nNone: If 'n' is equal to 0.\r\n\r\n### sumOfPrimes(n):\r\nCalculates the sum of the first 'n' prime numbers.<br><br>\r\n**Arguments**:<br>\r\nn (int): The first 'n' prime numbers to add up.<br><br>\r\n**Returns**:<br>\r\nint: The sum of the first n prime numbers.<br>\r\nNone: If 'n' is equal to 0.\r\n\r\n### theNthPrime(n):\r\nReturns the 'n'-th prime number.<br><br>\r\n**Arguments**:<br>\r\nn (int): The position of the prime number.<br><br>\r\n**Returns**:<br>\r\nint: The 'n'-th prime number.<br>\r\nNone: If 'n' is equal to 0.\r\n\r\n### sumOfDifferences(n):\r\nCalculates the sum of differences between the first 'n' prime numbers.<br><br>\r\n**Arguments**:<br>\r\nn (int): The first 'n' prime numbers to consider.<br><br>\r\n**Returns**:<br>\r\nint: The sum of the differences between the first 'n' prime numbers.<br>\r\nNone: If 'n' is equal to 0.\r\n\r\n### primeCounting(n):\r\nReturns the number of primes less than 'n'.<br><br>\r\n**Arguments**:<br>\r\nn (int): The positive integer for which you want to count the prime numbers less than it.<br><br>\r\n**Returns**:<br>\r\nint: The number of prime numbers less than 'n'.<br>\r\nNone: If 'n' is equal to 0.\r\n\r\n### lcm(n):\r\nCalculates the lowest common multiple of the first 'n' primes.<br><br>\r\n**Arguments**:<br>\r\nn (int): The first 'n' prime numbers to consider.<br><br>\r\n**Returns**:<br>\r\nint: The lowest common multiple of the first 'n' prime numbers<br>\r\nNone: If 'n' is equal to 0.\r\n\r\n### primeSlice(start, stop):\r\nReturns an array of prime numbers between 'start' and 'stop' (inclusive).<br><br>\r\n**Arguments**:<br>\r\nstart (int): The starting integer for the range.<br>\r\nstop (int): The ending integer for the range.<br><br>\r\n**Returns**:<br>\r\nlist: A list of prime numbers within the inclusive range from 'start' to 'stop'.\r\n\r\n### primeDifferenceSlice(start, stop):\r\nReturns an array of the differences between successive prime numbers between 'start' and 'stop' (inclusive).<br><br>\r\n**Arguments**:<br>\r\nstart (int): The starting integer for the range.<br>\r\nstop (int): The ending integer for the range.<br><br>\r\n**Returns**:<br>\r\nlist: A list of the differences between the prime numbers within the inclusive range from 'start' to 'stop'.\r\n\r\n### modifyValues(array, operation, operand):\r\nModifies an array using the specified 'operation' and 'operand' values.<br><br>\r\n**Arguments**:<br>\r\narray (arr): An array of integer values.<br>\r\noperation (str): The operation to perform on the prime numbers within the range. Valid values are \"multiply\" or \"*\", \"divide\" or \"/\", \"subtract\" or \"-\", \"add\" or \"+\", and \"exponent\" or \"^\".<br>\r\noperand (int, float or expression): The value to use as the operand for the specified operation.<br><br>\r\n**Returns**:<br>\r\nlist: A list of integers after applying the specified 'operation' and 'operand'.\r\n\r\n### randomPrimeSlice(start, stop, length):\r\nGenerates a random selection of prime numbers within the inclusive range from 'start' to 'stop'.<br><br>\r\n**Arguments**:<br>\r\nstart (int): The starting integer for the range.<br>\r\nstop (int): The ending integer for the range.<br>\r\nlength (int): The number of prime numbers to include in the random selection.<br><br>\r\n**Returns**:<br>\r\nlist: A list of prime numbers randomly selected from within the inclusive range between 'start' and 'stop'.<br>\r\nNone: 'length' is equal to 0.\r\n\r\n### randomDifferencesSlice(start, stop, length): \r\nGenerates a random selection of differences between successive prime numbers within the inclusive range from 'start' to 'stop'.<br><br>\r\n**Arguments**:<br>\r\nstart (int): The starting integer for the range.<br>\r\nstop (int): The ending integer for the range.<br>\r\nlength (int): The number of differences to include in the random range.<br><br>\r\n**Returns**:<br>\r\nlist: A list of the differences between prime numbers randomly selected from within the inclusive range between 'start' and 'stop'.<br>\r\nNone: 'length' is equal to 0. \r\n\r\n### graphDifferences(n):\r\nGraphs the differences between the first 'n' successive prime numbers.<br><br>\r\n**Arguments**:<br>\r\nn (int): The number of successive prime numbers to consider for generating the graph.<br><br>\r\n**Returns**:<br>\r\nThis function doesn't return any value; it generates and displays a graph.<br>\r\nNone: if 'n' is equal to 0.\r\n\r\n### graphPrimes(stop, operation, operand, start):\r\nPlots and displays a graph comparing a set of regular and modified prime numbers.<br><br>\r\n**Arguments**:<br>\r\nstop (int): The ending integer for the range of primes.<br>\r\noperation (str, optional): The mathematical operation to apply to the prime numbers. Valid values are \"multiply\" or \"*\", \"divide\" or \"/\", \"subtract\" or \"-\", \"add\" or \"+\", and \"exponent\" or \"^\". Defaults to addition (\"+\").<br>\r\noperand (int, float, or expression, optional): The value to use as the operand for the specified operation. Defaults to 0.<br>\r\nstart (int, optional): The starting integer for the range. Defaults to 1.<br><br>\r\n**Returns**:<br>\r\nThis function doesn't return any value; it generates and displays a graph.\r\n\r\n### sacksSpiral(n, coordinateRange, dotSize):\r\nDraws a Sacks Spiral representation of the first 'n' prime numbers.<br><br>\r\n**Arguments**:<br>\r\nn (int): The first 'n' prime numbers to consider for drawing the Sacks Spiral.<br>\r\ncoordinateRange (int, optional): The coordinate system's range for both axis. Defaults to 100.<br>\r\ndotSize (int, optional): The size of dots representing the prime numbers. Defaults to 5.<br><br>\r\n**Returns**:<br>\r\nThis function doesn't return any value; it generates and displays a drawing.\r\n\r\n### differenceSpiral(n, coordinateRange, dotSize):\r\nDraws a spiral using the same rules of the Sacks Spiral using non-repeating differences\r\nbetween the primes instead of the primes themselves. Uses turtle graphics library.<br><br>\r\n**Arguments**:<br>\r\nn (int): The limit of differences to consider for drawing the spiral.<br>\r\ncoordinateRange (int, optional): The coordinate system's range for both axis. Defaults to 15.<br>\r\ndotSize (int, optional): The size of dots representing the differences. Defaults to 10.<br><br>\r\n**Returns**:<br>\r\n This function doesn't return any value; it generates and displays a graph.\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](https://mit-license.org/) for more details.\r\n\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python module for working with prime numbers",
"version": "1.1.1",
"project_urls": {
"Homepage": "https://github.com/Langton49/workingWithPrimes"
},
"split_keywords": [
"prime",
"numbers",
"mathematics",
"math"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f4858ded83548ec6420be48b251a3750bbc6509fda114e0bef0a5c4baf8cae7d",
"md5": "598ea985f03d8050f276be2aa2bad0e6",
"sha256": "7339acacc64067e88d1f8c57cc71ccb2b8bf884d5e8a5c23ccaf3aacadad409c"
},
"downloads": -1,
"filename": "wwp-1.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "598ea985f03d8050f276be2aa2bad0e6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 7336,
"upload_time": "2023-10-20T17:00:41",
"upload_time_iso_8601": "2023-10-20T17:00:41.550396Z",
"url": "https://files.pythonhosted.org/packages/f4/85/8ded83548ec6420be48b251a3750bbc6509fda114e0bef0a5c4baf8cae7d/wwp-1.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "72cafdafd0763076a5dce966629234eb4913dcfa1ef33a0be78bc36e02fd568c",
"md5": "bec722174d3817983262810fd93eeb41",
"sha256": "bad937b6d341bce974f67364ed01f8edc51a1691e6fcb906c65bbc8e49d4e6e2"
},
"downloads": -1,
"filename": "wwp-1.1.1.tar.gz",
"has_sig": false,
"md5_digest": "bec722174d3817983262810fd93eeb41",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 7221,
"upload_time": "2023-10-20T17:00:42",
"upload_time_iso_8601": "2023-10-20T17:00:42.889931Z",
"url": "https://files.pythonhosted.org/packages/72/ca/fdafd0763076a5dce966629234eb4913dcfa1ef33a0be78bc36e02fd568c/wwp-1.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-20 17:00:42",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Langton49",
"github_project": "workingWithPrimes",
"github_not_found": true,
"lcname": "wwp"
}