How to resolve the algorithm Cuban primes step by step in the Transd programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Cuban primes step by step in the Transd programming language
Table of Contents
Problem Statement
The name cuban has nothing to do with Cuba (the country), but has to do with the fact that cubes (3rd powers) play a role in its definition.
Cuban primes were named in 1923 by Allan Joseph Champneys Cunningham.
Note that cuban prime isn't capitalized (as it doesn't refer to the nation of Cuba).
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Cuban primes step by step in the Transd programming language
Source code in the transd programming language
#lang transd
MainModule: {
primes: Vector([3, 5]),
lim: 200,
bigUn: 100000,
chunks: 50,
little: 0,
c: 0,
showEach: true,
u: ULong(0),
v: ULong(1),
_start: (λ found Bool() fnd Bool() mx Int() z ULong()
(= little (/ bigUn chunks))
(for i in Range(1 (pow 2 20)) do
(= found false)
(+= u 6) (+= v u) (= mx (to-Int (sqrt v) 1))
(for item in primes do
(if (> item mx) break)
(if (not (mod v item)) (= found true)
break))
(if (not found)
(+= c 1)
(if showEach
(= z (get primes -1))
(while (< z (- v 2))
(+= z 2) (= fnd false)
(for item in primes do
(if (> item mx) break)
(if (not (mod z item)) (= fnd true)
break))
(if (not fnd) (append primes z)))
(append primes v)
(textout :width 11 :group v)
(if (not (mod c 10)) (textout :nl))
(if (== c lim) (= showEach false)
(textout "Progress to the " :group bigUn
"'th cuban prime:" ))
)
(if (not (mod c little)) (textout "."))
(if (== c bigUn) break)
)
)
(lout "The " :group c "'th cuban prime is " v )
)
}
You may also check:How to resolve the algorithm Mad Libs step by step in the C programming language
You may also check:How to resolve the algorithm Hough transform step by step in the Raku programming language
You may also check:How to resolve the algorithm Increasing gaps between consecutive Niven numbers step by step in the REXX programming language
You may also check:How to resolve the algorithm Superpermutation minimisation step by step in the Ruby programming language
You may also check:How to resolve the algorithm Sequence: nth number with exactly n divisors step by step in the Python programming language