How to resolve the algorithm Penta-power prime seeds step by step in the Nim programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Penta-power prime seeds step by step in the Nim programming language
Table of Contents
Problem Statement
Generate the sequence of penta-power prime seeds: positive integers n such that:
I can find no mention or record of this sequence anywhere. Perhaps I've invented it.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Penta-power prime seeds step by step in the Nim programming language
Source code in the nim programming language
import std/[strformat, strutils]
import integers
func isPentaPowerPrimeSeeds(n: Integer): bool =
var p = newInteger(1)
var n1 = n + 1
for _ in 0..4:
if not isPrime(p + n1): return false
p *= n
result = true
const N = 10_000_000
echo "First 30 penta-power prime seeds:"
var count = 0
var n = 1
while true:
if n.isPentaPowerPrimeSeeds():
inc count
if count <= 30:
stdout.write &"{n:7}"
stdout.write if count mod 6 == 0: '\n' else: ' '
if count == 30: echo()
elif n > N:
echo &"First penta-power prime seed greater than {insertSep($N)} " &
&"is {insertSep($n)} at position {count}."
break
inc n, 2
You may also check:How to resolve the algorithm Anagrams step by step in the 11l programming language
You may also check:How to resolve the algorithm ABC problem step by step in the PHP programming language
You may also check:How to resolve the algorithm Loops/While step by step in the Quackery programming language
You may also check:How to resolve the algorithm MD5/Implementation step by step in the 11l programming language
You may also check:How to resolve the algorithm Function definition step by step in the Coco programming language