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.



Task

 Write a routine (function, procedure, whatever) to find Pierpont primes of the first & second kinds.
 Use the routine to find and display here, on this page, the first 50 Pierpont primes of the first kind.
 Use the routine to find and display here, on this page, the first 50 Pierpont primes of the second kind
 If your language supports large integers, find and display here, on this page, the 250th Pierpont prime of the first kind and the 250th Pierpont prime of the second kind.


See also

 Wikipedia - Pierpont primes
 OEIS:A005109 - Class 1 -, or Pierpont primes
 OEIS:A005105 - Class 1 +, or Pierpont primes of the second kind


 
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
 