PPY_PRIMEBETWEEN
This function returns prime numbers within a bounded integer interval.
The output contains integers p that satisfy the interval conditions imposed by primePy’s between function and are prime.
Results are formatted as a single-column 2D array for Excel range compatibility.
Excel Usage
=PPY_PRIMEBETWEEN(m, n)
m(int, required): Lower bound of interval.n(int, required): Upper bound of interval.
Returns (list[list]): Single-column 2D array of prime numbers between m and n.
Example 1: Primes between ten and thirty
Inputs:
| m | n |
|---|---|
| 10 | 30 |
Excel formula:
=PPY_PRIMEBETWEEN(10, 30)
Expected output:
| Result |
|---|
| 11 |
| 13 |
| 17 |
| 19 |
| 23 |
| 29 |
Example 2: Primes between two and ten
Inputs:
| m | n |
|---|---|
| 2 | 10 |
Excel formula:
=PPY_PRIMEBETWEEN(2, 10)
Expected output:
| Result |
|---|
| 3 |
| 5 |
| 7 |
Example 3: Primes between fifty and eighty
Inputs:
| m | n |
|---|---|
| 50 | 80 |
Excel formula:
=PPY_PRIMEBETWEEN(50, 80)
Expected output:
| Result |
|---|
| 53 |
| 59 |
| 61 |
| 67 |
| 71 |
| 73 |
| 79 |
Example 4: Primes in a small interval window
Inputs:
| m | n |
|---|---|
| 90 | 100 |
Excel formula:
=PPY_PRIMEBETWEEN(90, 100)
Expected output:
97
Python Code
from primePy import primes as primepy_primes
def ppy_primebetween(m, n):
"""
List prime numbers between two bounds using primePy.
See: https://github.com/janaindrajit/primePy
This example function is provided as-is without any representation of accuracy.
Args:
m (int): Lower bound of interval.
n (int): Upper bound of interval.
Returns:
list[list]: Single-column 2D array of prime numbers between m and n.
"""
try:
values = primepy_primes.between(m, n)
return [[int(v)] for v in values]
except Exception as e:
return f"Error: {str(e)}"Online Calculator
Lower bound of interval.
Upper bound of interval.