This article is half-done without your Comment! *** Please share your thoughts via Comment ***
Check the below input data and expected output to generate the Fibonacci Series for first 10 digits.
Expected Output:
1 2 3 4 5 6 7 8 9 10 11 12 |
FibonacciNumber --------------- 0 1 1 2 3 5 8 13 21 34 |
Solution:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
;WITH CTE AS ( SELECT 0 AS Level ,0 AS Start ,1 AS Next UNION ALL SELECT t.Level + 1 ,t.Next ,t.Start + t.Next FROM CTE t WHERE t.Level < ( 10 - 1 ) ) SELECT Start as FibonacciNumber FROM CTE OPTION (MAXRECURSION 10000) |
Please try the different solution for this puzzle and share it via comment...
Leave a Reply