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

Published on 12 May 2024 09:40 PM

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

Table of Contents

Problem Statement

An   emirp   (prime spelled backwards)   are primes that when reversed   (in their decimal representation)   are a different prime. (This rules out palindromic primes.)

In each list, the numbers should be in order. Invoke the (same) program once per task requirement, this will show what limit is used as the upper bound for calculating surplus (regular) primes. The specific method of how to determine if a range or if specific values are to be shown will be left to the programmer.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Emirp primes step by step in the Arturo programming language

Source code in the arturo programming language

emirps: function [upto][
    result: new []
    loop range .step: 2 11 upto 'x [
        if prime? x [
            reversed: to :integer reverse to :string x
            if x <> reversed [
                if prime? reversed ->
                    'result ++ x
            ]
        ]
    ]
    return result
]

lst: emirps 1000000

print "The first 20 emirps:"
print first.n: 20 lst

print ""
print "Emirps between 7700 and 8000:"
print select lst 'x -> and? x > 7700 x < 8000

print ""
print "The 10000th emirp:"
print lst\9999


  

You may also check:How to resolve the algorithm Elementary cellular automaton/Random number generator step by step in the Julia programming language
You may also check:How to resolve the algorithm Date format step by step in the min programming language
You may also check:How to resolve the algorithm System time step by step in the PARI/GP programming language
You may also check:How to resolve the algorithm Plot coordinate pairs step by step in the PARI/GP programming language
You may also check:How to resolve the algorithm String case step by step in the Zoea programming language