How to resolve the algorithm Prime numbers whose neighboring pairs are tetraprimes step by step in the Phix programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Prime numbers whose neighboring pairs are tetraprimes step by step in the Phix programming language

Table of Contents

Problem Statement

The following definitions are needed for this task. A tetraprime is a positive integer which is the product of four distinct primes. For example, 1155 is a tetraprime because 1155 = 3 x 5 x 7 x 11. The neighboring pairs of a prime are the two consecutive numbers immediately preceding or immediately following that prime. For example, (5, 6) and (8, 9) are the neighboring pairs of the prime 7.

  1. Find and show here all primes less than 100,000 whose preceding neighboring pair are both tetraprimes.
  2. Find and show here all primes less than 100,000 whose following neighboring pair are both tetraprimes.
  3. Of the primes in 1 and 2 above how many have a neighboring pair one of whose members has a prime factor of 7?
  4. For the primes in 1 and 2 above, consider the gaps between consecutive primes. What are the minimum, median and maximum gaps?
  5. Repeat these calculations for all primes less than 1 million but for 1 and 2 just show the number of primes - don't print them out individually. If it is difficult for your language to meet all of these requirements, then just do what you reasonably can.

Repeat the calculations for all primes less than 10 million.

Let's start with the solution: