How to resolve the algorithm Multifactorial step by step in the MAD programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Multifactorial step by step in the MAD 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 MAD programming language

Source code in the mad programming language

            NORMAL MODE IS INTEGER
            
            INTERNAL FUNCTION(N,DEG)
            ENTRY TO MLTFAC.
            RSLT = 1
            THROUGH MULT, FOR MPC=N, -DEG, MPC.L.1
MULT        RSLT = RSLT * MPC
            FUNCTION RETURN RSLT
            END OF FUNCTION
            
            THROUGH SHOW, FOR I=1, 1, I.G.10
SHOW        PRINT FORMAT OUTP, MLTFAC.(I,1), MLTFAC.(I,2), 
          0      MLTFAC.(I,3), MLTFAC.(I,4), MLTFAC.(I,5)
           
            VECTOR VALUES OUTP = $5(I10,S1)*$
            END OF PROGRAM

  

You may also check:How to resolve the algorithm Day of the week step by step in the MATLAB / Octave programming language
You may also check:How to resolve the algorithm Wieferich primes step by step in the Go programming language
You may also check:How to resolve the algorithm CSV data manipulation step by step in the C++ programming language
You may also check:How to resolve the algorithm Define a primitive data type step by step in the Modula-3 programming language
You may also check:How to resolve the algorithm Loops/For with a specified step step by step in the jq programming language