如何生成斐波那契数列 [英] How to generate Fibonacci Series
本文介绍了如何生成斐波那契数列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在sql中生成斐波那契数列!
How to Generate Fibonacci series in sql !
我需要生成斐波那契数列 0 1 1 2 3 5 8 13 21 ... N
I need to generate Fibonacci series 0 1 1 2 3 5 8 13 21 ... N
我使用 C 代码很容易做到了我需要使用 Sql 做到这一点!
I did this easily using C-code I need to do this using Sql !
推荐答案
试试这个!
declare @a int
declare @b int
declare @c int
Declare @i int
set @a=0
set @b=1
set @i=0
set @c=0
Print 'Fibonacci Series'
print @a
print @b
while @i<10
Begin
set @c=@a+@b
print @c
set @i=@i+1
set @a=@b
set @b=@c
end
输出!
Fibonacci Series
01123581321345589
0 1 1 2 3 5 8 13 21 34 55 89
这篇关于如何生成斐波那契数列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文