How to resolve the algorithm Pierpont primes step by step in the Ring programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Pierpont primes step by step in the Ring programming language

Table of Contents

Problem Statement

A Pierpont prime is a prime number of the form: 2u3v + 1 for some non-negative integers u and v .

A Pierpont prime of the second kind is a prime number of the form: 2u3v - 1 for some non-negative integers u and v .

The term "Pierpont primes" is generally understood to mean the first definition, but will be called "Pierpont primes of the first kind" on this page to distinguish them.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Pierpont primes step by step in the Ring programming language

Source code in the ring programming language

load "stdlib.ring"

see "working..." + nl

pierpont = []
limit1 = 18
limit2 = 8505000
limit3 = 50
limit4 = 21
limit5 = 30500000

for n = 0 to limit1
    for m = 0 to limit1
        num = pow(2,n)*pow(3,m) + 1
        if isprime(num) and num < limit2 
           add(pierpont,num)
        ok
        if num > limit2
           exit
        ok
     next
next

pierpont = sort(pierpont)

see "First 50 Pierpont primes of the first kind:" + nl + nl

for n = 1 to limit3
    see "" + n + ". " + pierpont[n] + nl
next

see "done1..." + nl

pierpont = []

for n = 0 to limit4
    for m = 0 to limit4
        num = pow(2,n)*pow(3,m) - 1
        if isprime(num) and num < limit5
           add(pierpont,num)
        ok
        if num > limit5
           exit
        ok
     next
next

pierpont = sort(pierpont)

see "First 50 Pierpont primes of the second kind:" + nl + nl

for n = 1 to limit3
    see "" + n + ". " + pierpont[n] + nl
next

see "done2..." + nl

  

You may also check:How to resolve the algorithm Sort an integer array step by step in the AppleScript programming language
You may also check:How to resolve the algorithm Include a file step by step in the Quackery programming language
You may also check:How to resolve the algorithm Averages/Root mean square step by step in the Morfa programming language
You may also check:How to resolve the algorithm Abstract type step by step in the Nit programming language
You may also check:How to resolve the algorithm Stirling numbers of the second kind step by step in the Mathematica / Wolfram Language programming language