How to resolve the algorithm Factorial step by step in the PL/I programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Factorial step by step in the PL/I 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 PL/I programming language
Source code in the pl/i programming language
factorial: procedure (N) returns (fixed decimal (30));
declare N fixed binary nonassignable;
declare i fixed decimal (10);
declare F fixed decimal (30);
if N < 0 then signal error;
F = 1;
do i = 2 to N;
F = F * i;
end;
return (F);
end factorial;
You may also check:How to resolve the algorithm Levenshtein distance step by step in the ZX Spectrum Basic programming language
You may also check:How to resolve the algorithm Comments step by step in the Visual Basic programming language
You may also check:How to resolve the algorithm Palindrome dates step by step in the 11l programming language
You may also check:How to resolve the algorithm Arithmetic/Integer step by step in the SmallBASIC programming language
You may also check:How to resolve the algorithm Stirling numbers of the second kind step by step in the C++ programming language