factorial

factorial

DELIMITER $$

DROP PROCEDURE IF EXISTS `FACTORIAL` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `FACTORIAL`(
  IN N BIGINT(20),
  OUT FACT BIGINT(20)
)
BEGIN
SET @@max_sp_recursion_depth = 60;
IF N = 1 THEN
  SELECT 1 INTO FACT;
ELSE
  CALL FACTORIAL(N-1, @RET);
  SELECT N*@RET INTO FACT;
END IF;
END $$

DELIMITER ;

 

 

你可能感兴趣的:(RIA)