How to resolve the algorithm Multifactorial step by step in the PARI/GP programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Multifactorial step by step in the PARI/GP programming language

Table of Contents

Problem Statement

The factorial of a number, written as

n !

{\displaystyle n!}

, is defined as

n !

n ( n − 1 ) ( n − 2 ) . . . ( 2 ) ( 1 )

{\displaystyle n!=n(n-1)(n-2)...(2)(1)}

. Multifactorials generalize factorials as follows: In all cases, the terms in the products are positive integers. If we define the degree of the multifactorial as the difference in successive terms that are multiplied together for a multifactorial (the number of exclamation marks), then the task is twofold:

Note: The wikipedia entry on multifactorials gives a different formula. This task uses the Wolfram mathworld definition.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Multifactorial step by step in the PARI/GP programming language

Source code in the pari/gp programming language

fac(n,d)=prod(k=0,(n-1)\d,n-k*d)
for(k=1,5,for(n=1,10,print1(fac(n,k)" "));print)

  

You may also check:How to resolve the algorithm Walk a directory/Non-recursively step by step in the Objective-C programming language
You may also check:How to resolve the algorithm Interactive programming (repl) step by step in the Wren programming language
You may also check:How to resolve the algorithm Random number generator (included) step by step in the Racket programming language
You may also check:How to resolve the algorithm Koch curve step by step in the Quackery programming language
You may also check:How to resolve the algorithm Ruth-Aaron numbers step by step in the Raku programming language