Friday, March 13, 2015

Write recursive t-sql code to get Factorial of integer number

Create Function dbo.fn_Factorial(@v_Number bigint)
Returns bigint
as
BeginIf (@v_Number != 1)
go
Select dbo.fn_Factorial(6)

Begin
return @v_Number * dbo.fn_Factorial(@v_Number - 1)
End
return 1
End
go

No comments:

Post a Comment