How to resolve the algorithm Additive primes step by step in the Quackery programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Additive primes step by step in the Quackery programming language

Table of Contents

Problem Statement

In mathematics, additive primes are prime numbers for which the sum of their decimal digits are also primes.

Write a program to determine (and show here) all additive primes less than 500. Optionally, show the number of additive primes.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Additive primes step by step in the Quackery programming language

Source code in the quackery programming language

  500 eratosthenes
  
  []
  500 times
    [ i^ isprime if
        [ i^ 10 digitsum 
          isprime if
            [ i^ join ] ] ] 
  dup echo cr cr
  size echo say " additive primes found."

  

You may also check:How to resolve the algorithm Terminal control/Clear the screen step by step in the Icon and Unicon programming language
You may also check:How to resolve the algorithm Sorting algorithms/Cocktail sort step by step in the REXX programming language
You may also check:How to resolve the algorithm Strip a set of characters from a string step by step in the RPL programming language
You may also check:How to resolve the algorithm Parallel calculations step by step in the Java programming language
You may also check:How to resolve the algorithm Currency step by step in the Maple programming language