How to resolve the algorithm Cuban primes step by step in the Arturo programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Cuban primes step by step in the Arturo 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 Arturo programming language

Source code in the arturo programming language

cubes: map 1..780000 'x -> x^3

cubans: []
i: 1
while [100000 > size cubans][
    num: cubes\[i] - cubes\[i-1]
    if prime? num ->
        'cubans ++ num
    inc 'i
]

first200primes: first.n: 200 cubans

loop split.every: 10 first200primes 'x ->
    print map x 's -> pad to :string s 8

print ""
print ["The 100000th Cuban prime is" last cubans]


  

You may also check:How to resolve the algorithm Case-sensitivity of identifiers step by step in the AutoHotkey programming language
You may also check:How to resolve the algorithm Array concatenation step by step in the SASL programming language
You may also check:How to resolve the algorithm Haversine formula step by step in the Oberon-2 programming language
You may also check:How to resolve the algorithm Greatest element of a list step by step in the TI-89 BASIC programming language
You may also check:How to resolve the algorithm Tree traversal step by step in the Smalltalk programming language