MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / compute_truncated_primes

Function compute_truncated_primes

project_euler/problem_037/sol1.py:94–108  ·  view source on GitHub ↗

Returns the list of truncated primes >>> compute_truncated_primes(11) [23, 37, 53, 73, 313, 317, 373, 797, 3137, 3797, 739397]

(count: int = 11)

Source from the content-addressed store, hash-verified

92
93
94def compute_truncated_primes(count: int = 11) -> list[int]:
95 """
96 Returns the list of truncated primes
97 >>> compute_truncated_primes(11)
98 [23, 37, 53, 73, 313, 317, 373, 797, 3137, 3797, 739397]
99 """
100 list_truncated_primes: list[int] = []
101 num = 13
102 while len(list_truncated_primes) != count:
103 if validate(num):
104 list_nums = list_truncated_nums(num)
105 if all(is_prime(i) for i in list_nums):
106 list_truncated_primes.append(num)
107 num += 2
108 return list_truncated_primes
109
110
111def solution() -> int:

Callers 2

solutionFunction · 0.85
sol1.pyFile · 0.85

Calls 4

list_truncated_numsFunction · 0.85
validateFunction · 0.70
is_primeFunction · 0.70
appendMethod · 0.45

Tested by

no test coverage detected