How to resolve the algorithm Left factorials step by step in the Arturo programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Left factorials step by step in the Arturo programming language

Table of Contents

Problem Statement

Left factorials,   !n,   may refer to either   subfactorials   or to   factorial sums; the same notation can be confusingly seen being used for the two different definitions. Sometimes,   subfactorials   (also known as derangements)   may use any of the notations:

(It may not be visually obvious, but the last example uses an upside-down exclamation mark.)

This Rosetta Code task will be using this formula   (factorial sums)   for   left factorial:

Display the left factorials for:

Display the length (in decimal digits) of the left factorials for:

Let's start with the solution:

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

Source code in the arturo programming language

lfactorial: function [n][
    if zero? n -> return 0
    fold 0..dec n [x y] -> x + factorial y
]

print "First eleven:"
0..10 | map => lfactorial
      | print

print "\n20th through 110th by tens:"
r: range.step: 10 20 110
r | map => lfactorial
  | loop => print

print "\nDigits in 1,000th through 10,000th by thousands:"
r: range.step: 1000 1000 10000
r | map'x -> size ~"|lfactorial x|"
  | print


  

You may also check:How to resolve the algorithm Reflection/List methods step by step in the Wren programming language
You may also check:How to resolve the algorithm String interpolation (included) step by step in the jq programming language
You may also check:How to resolve the algorithm Modified random distribution step by step in the Ruby programming language
You may also check:How to resolve the algorithm Map range step by step in the FutureBasic programming language
You may also check:How to resolve the algorithm Filter step by step in the Ol programming language