delimiter // CREATE PROCEDURE fact(IN x BIGINT) BEGIN DECLARE result BIGINT; DECLARE i BIGINT; SET result = 1; SET i = 1; WHILE i <= x DO SET result = result * i; SET i = i + 1; END WHILE; SELECT x AS Number, result as Factorial; END// delimiter ;