How to resolve the algorithm Long primes step by step in the J programming language

Published on 12 May 2024 09:40 PM
#J

How to resolve the algorithm Long primes step by step in the J programming language

Table of Contents

Problem Statement

A   long prime   (as defined here)   is a prime number whose reciprocal   (in decimal)   has a   period length   of one less than the prime number.

Long primes   are also known as:

Another definition:   primes   p   such that the decimal expansion of   1/p   has period   p-1,   which is the greatest period possible for any integer.

7   is the first long prime,   the reciprocal of seven is   1/7,   which is equal to the repeating decimal fraction   0.142857142857··· The length of the   repeating   part of the decimal fraction is six,   (the underlined part)   which is one less than the (decimal) prime number   7. Thus   7   is a long prime.

There are other (more) general definitions of a   long prime   which include wording/verbiage for bases other than ten.

Let's start with the solution: