How to resolve the algorithm Sphenic numbers step by step in the RPL programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Sphenic numbers step by step in the RPL programming language

Table of Contents

Problem Statement

A sphenic number is a positive integer that is the product of three distinct prime numbers. More technically it's a square-free 3-almost prime (see Related tasks below). For the purposes of this task, a sphenic triplet is a group of three sphenic numbers which are consecutive. Note that sphenic quadruplets are not possible because every fourth consecutive positive integer is divisible by 4 (= 2 x 2) and its prime factors would not therefore be distinct. 30 (= 2 x 3 x 5) is a sphenic number and is also clearly the first one. [1309, 1310, 1311] is a sphenic triplet because 1309 (= 7 x 11 x 17), 1310 (= 2 x 5 x 31) and 1311 (= 3 x 19 x 23) are 3 consecutive sphenic numbers. Calculate and show here:

  1. All sphenic numbers less than 1,000.
  2. All sphenic triplets less than 10,000.
  3. How many sphenic numbers are there less than 1 million?
  4. How many sphenic triplets are there less than 1 million?
  5. What is the 200,000th sphenic number and its 3 prime factors?
  6. What is the 5,000th sphenic triplet? Hint: you only need to consider sphenic numbers less than 1 million to answer 5. and 6.

Let's start with the solution: