CREATE PROC [dbo].[usp_spFactorial]
@InputValue INT,
@OuputValue INT OUTPUT
AS
BEGIN
DECLARE @InValue INT;
DECLARE @OutValue INT;
IF(@InputValue!=1)
BEGIN
SET @InValue = @InputValue - 1;
EXEC spFactorial @InValue,@OutValue OUTPUT;
SELECT @OuputValue = @InputValue * @OutValue;
END
ELSE
BEGIN
SET @OuputValue = 1;
END
END