How to resolve the algorithm Factorial step by step in the Bracmat programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Factorial step by step in the Bracmat programming language
Table of Contents
Problem Statement
Write a function to return the factorial of a number. Solutions can be iterative or recursive. Support for trapping negative n errors is optional.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Factorial step by step in the Bracmat programming language
Source code in the bracmat programming language
(
=
. !arg:0&1
| !arg
* ( (
= r
. !arg:?r
&
' (
. !arg:0&1
| !arg*(($r)$($r))$(!arg+-1)
)
)
$ (
= r
. !arg:?r
&
' (
. !arg:0&1
| !arg*(($r)$($r))$(!arg+-1)
)
)
)
$ (!arg+-1)
)
$ 10
: 3628800
( (=(r.!arg:?r&'(.!arg:0&1|!arg*(($r)$($r))$(!arg+-1)))):?g
& (!g$!g):?f
& !f$10
)
(factorial=
r
. !arg:?r
& whl
' (!arg:>1&(!arg+-1:?arg)*!r:?r)
& !r
);
You may also check:How to resolve the algorithm User input/Graphical step by step in the Sidef programming language
You may also check:How to resolve the algorithm Reverse a string step by step in the Lang5 programming language
You may also check:How to resolve the algorithm SHA-256 step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Substring/Top and tail step by step in the Python programming language
You may also check:How to resolve the algorithm Caesar cipher step by step in the Action! programming language