How to resolve the algorithm Factorions step by step in the Arturo programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Factorions step by step in the Arturo programming language

Table of Contents

Problem Statement

A factorion is a natural number that equals the sum of the factorials of its digits.

145   is a factorion in base 10 because:

It can be shown (see talk page) that no factorion in base 10 can exceed   1,499,999.

Write a program in your language to demonstrate, by calculating and printing out the factorions, that:

Let's start with the solution:

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

Source code in the arturo programming language

factorials: [1 1 2 6 24 120 720 5040 40320 362880 3628800 39916800]

factorion?: function [n, base][
    try? [
        n = sum map digits.base:base n 'x -> factorials\[x]
    ]
    else [
        print ["n:" n "base:" base]
        false
    ]
]

loop 9..12 'base ->
    print ["Base" base "factorions:" select 1..45000 'z -> factorion? z base]
]


  

You may also check:How to resolve the algorithm Search a list step by step in the M2000 Interpreter programming language
You may also check:How to resolve the algorithm Compile-time calculation step by step in the Rust programming language
You may also check:How to resolve the algorithm Sokoban step by step in the Raku programming language
You may also check:How to resolve the algorithm Generator/Exponential step by step in the D programming language
You may also check:How to resolve the algorithm Bitmap/Bézier curves/Quadratic step by step in the XPL0 programming language