primes
is_prime(number)
States if a number is prime.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
number |
int
|
A number |
required |
Returns:
Type | Description |
---|---|
bool
|
Whether or not the number is prime |
Examples:
>>> is_prime(31)
True
>>> is_prime(42)
False
Source code in /opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/jintonic/primes.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
generate_primes(limit)
Generates primes up to a given limit.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
limit |
int
|
The limit. |
required |
Returns:
Type | Description |
---|---|
List[int]
|
Primes |
Examples:
>>> generate_primes(31)
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
Source code in /opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/jintonic/primes.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
prime_factors(number)
Finds prime factors of an integer (by trial-division).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
number |
int
|
The integer to factor |
required |
Returns:
Type | Description |
---|---|
List[int]
|
Prime factors |
Examples:
>>> prime_factors(314)
[2, 157]
>>> prime_factors(31)
[31]
Source code in /opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/jintonic/primes.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
lcm(numbers)
Least common multiple of a list of integers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
numbers |
List[int]
|
List of integers |
required |
Returns:
Type | Description |
---|---|
int
|
Least common multiple |
Examples:
>>> lcm([15, 3, 5])
15
>>> lcm([21, 6, 7])
42
Source code in /opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/jintonic/primes.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|