aboutsummaryrefslogtreecommitdiff
path: root/challenge-158/lubos-kolouch/python/ch-1.py
blob: 5e32ad5748c8b3070cd08ec44971526b0b4a3d64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Challenge 158 Task 1
from sympy import isprime, nextprime


def get_additive_primes(limit: int) -> list:
    """Get the list of primes"""

    pos = 1
    primes = []

    while pos <= limit:

        if isprime(pos) and isprime(sum(list(map(int, str(pos))))):
            primes.append(pos)

        pos = nextprime(pos)

    return primes


assert get_additive_primes(100) == [2, 3, 5, 7, 11, 23, 29, 41, 43, 47, 61, 67, 83, 89]