PPY_PRIMEUPTO

This function returns all primes less than or equal to a maximum integer bound.

The result contains each integer p such that 2 \le p \le n and p is prime.

Values are returned as a single-column 2D array for Excel output.

Excel Usage

=PPY_PRIMEUPTO(n)
  • n (int, required): Inclusive upper bound for generated primes.

Returns (list[list]): Single-column 2D array of prime numbers up to n.

Example 1: Primes up to ten

Inputs:

n
10

Excel formula:

=PPY_PRIMEUPTO(10)

Expected output:

Result
2
3
5
7
Example 2: Primes up to thirty

Inputs:

n
30

Excel formula:

=PPY_PRIMEUPTO(30)

Expected output:

Result
2
3
5
7
11
13
17
19
23
29
Example 3: Primes up to two

Inputs:

n
2

Excel formula:

=PPY_PRIMEUPTO(2)

Expected output:

2

Example 4: Primes up to one hundred

Inputs:

n
100

Excel formula:

=PPY_PRIMEUPTO(100)

Expected output:

Result
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

Python Code

from primePy import primes as primepy_primes

def ppy_primeupto(n):
    """
    List all prime numbers up to a maximum value using primePy.

    See: https://github.com/janaindrajit/primePy

    This example function is provided as-is without any representation of accuracy.

    Args:
        n (int): Inclusive upper bound for generated primes.

    Returns:
        list[list]: Single-column 2D array of prime numbers up to n.
    """
    try:
        values = primepy_primes.upto(n)
        return [[int(v)] for v in values]
    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

Inclusive upper bound for generated primes.