Create PROCEDURE Factorial
@Number as int,
@Factorial as int OUTPUT
AS
Begin
DECLARE @Input int
DECLARE @Output int
IF @Number != 1
BEGIN
set @Input = @Number - 1
EXEC Factorial @Input, @Output OUTPUT
SELECT @Factorial = @Number * @Output
END
ELSE
BEGIN
SELECT @Factorial = 1
END
RETURN
End
Tuesday, July 28, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment