PseudoChartPseudoChart

Factorial (Recursive)

Global

Recursion

Created by pattakorn.k on Oct 1, 2026

Pseudocode
// PSC:1.0 Factorial
// Description: Computes n! with a function that calls itself

FUNCTION factorial(n)
  IF n <= 1
    RETURN 1
  END IF
  LET smaller = CALL factorial(n - 1)
  RETURN n * smaller
END FUNCTION

BEGIN Factorial
  INPUT "Enter a whole number: " n
  IF n < 0
    OUTPUT "Factorial is not defined for negative numbers"
  ELSE
    LET result = CALL factorial(n)
    OUTPUT n "! = " result
  END IF
END
Interactive Preview
Generating flowchart…