Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
CREATE FUNCTION dbo.fnFactorial( @principal int )
RETURNS int
AS
BEGIN
DECLARE @factorial int, @cntr int
SELECT @cntr = 1, @factorial = 1
WHILE @cntr <= @principal
SELECT @factorial = @factorial * @cntr,
@cntr = @cntr + 1
RETURN @factorial
END
-----------------------------
SELECT dbo.fnFactorial(6)
create function howmanyfactdigits(@n int)
returns int
as
begin
declare @digits float; set @digits = 0
while @n > 1
begin
set @digits = @digits + log10(@n)
set @n = @n-1
end
return 1 + convert(int, @digits)
end