How to resolve the algorithm Descending primes step by step in the Wren programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Descending primes step by step in the Wren programming language

Table of Contents

Problem Statement

Generate and show all primes with strictly descending decimal digits.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Descending primes step by step in the Wren programming language

Source code in the wren programming language

import "./perm" for Powerset
import "./math" for Int
import "./seq" for Lst
import "./fmt" for Fmt

var ps = Powerset.list((9..1).toList)
var descPrimes = ps.skip(1).map { |s| Num.fromString(s.join()) }
                           .where { |p| Int.isPrime(p) }
                           .toList
                           .sort()
System.print("There are %(descPrimes.count) descending primes, namely:")
Fmt.tprint("$8s", descPrimes, 10)


  

You may also check:How to resolve the algorithm Image convolution step by step in the OCaml programming language
You may also check:How to resolve the algorithm Handle a signal step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Rate counter step by step in the C++ programming language
You may also check:How to resolve the algorithm Inverted index step by step in the C programming language
You may also check:How to resolve the algorithm Trabb Pardo–Knuth algorithm step by step in the PARI/GP programming language