Answers for "factorial formula by recursive algorithm"

C++
2

recursion factorial algorithm

FUNCTION FACTORIAL (N: INTEGER): INTEGER
(* RECURSIVE COMPUTATION OF N FACTORIAL *)

BEGIN
  (* TEST FOR STOPPING STATE *)
  IF N <= 0 THEN
    FACTORIAL := 1
  ELSE
    FACTORIAL := N * FACTORIAL(N - 1)
END; (* FACTORIAL *)
Posted by: Guest on December-29-2020
0

factorial recursive

N= int(input())
def fun(n):
    if n ==1 or n==0:
        return 1
    else:
        n = n * fun(n-1)
        return n 


print(fun(N))
Posted by: Guest on June-26-2021
0

recursive factorial of a number

factorial(N){
    if(N<=1)
    {
      return 1;
    }
    else
    {
      return (N*factorial(N-1));
    }
}
Posted by: Guest on January-11-2022

Browse Popular Code Answers by Language