How to resolve the algorithm Multifactorial step by step in the Ol programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Multifactorial step by step in the Ol 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 Ol programming language
Source code in the ol programming language
(define (multifactorial n d)
(fold * 1 (iota (div n d) n (negate d))))
(for-each (lambda (i)
(display "Degree ")
(display i)
(display ":")
(for-each (lambda (n)
(display " ")
(display (multifactorial n i)))
(iota 10 1))
(print))
(iota 5 1))
(define (!!!!! n) (multifactorial n 5))
(print (!!!!! 74))
(import (math infix-notation))
; register !!!!! as a postfix function
(define \\postfix-functions (put \\postfix-functions '!!!!! #t))
; now use "\\" as usual
(print (\\
2 + 74!!!!!
))
You may also check:How to resolve the algorithm Tic-tac-toe step by step in the Scilab programming language
You may also check:How to resolve the algorithm Ascending primes step by step in the Fortran programming language
You may also check:How to resolve the algorithm Guess the number step by step in the Quackery programming language
You may also check:How to resolve the algorithm Rosetta Code/Rank languages by popularity step by step in the Nim programming language
You may also check:How to resolve the algorithm Plasma effect step by step in the Go programming language