FiSGO.PrimesHandler.primes

primes(n, primes_path='/home/docs/checkouts/readthedocs.org/user_builds/fisgo/checkouts/latest/FiSGO/PrecomputedData/BuiltinPrimes.txt')[source]

Given an integer n, returns a generator of the first n primes in file primes_path.

File primes_path is specified to PRIMES_PATH by default, containing 10^5 first primes; primes_path should refer to a file where each line contains a single prime number, in ascending order, see PRIMES_PATH for an example of the required format.

If n exceeds the maximum number of prime numbers available in the file primes_path, the function will raise a ValueError.

Parameters:
  • n (int) – Positive integer, maximum number of primes for the generator.

  • primes_path – Path to a file with an ordered list of prime numbers.

Return type:

Generator[int, None, None]

Returns:

Generator of the first n prime numbers.