How to resolve the algorithm Factorial step by step in the Déjà Vu programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Factorial step by step in the Déjà Vu 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 Déjà Vu programming language

Source code in the déjà programming language

factorial:
    1
    while over:
        * over
        swap -- swap
    drop swap

factorial:
    if dup:
        * factorial -- dup
    else:
        1 drop

  

You may also check:How to resolve the algorithm Function composition step by step in the VBScript programming language
You may also check:How to resolve the algorithm FizzBuzz step by step in the Enguage programming language
You may also check:How to resolve the algorithm Count occurrences of a substring step by step in the UNIX Shell programming language
You may also check:How to resolve the algorithm Sleep step by step in the Elena programming language
You may also check:How to resolve the algorithm Sorting algorithms/Shell sort step by step in the ALGOL 68 programming language