ksdf.net
当前位置:首页>>关于已知fibonacci数列:1,1,2,3,5,8,......,它...的资料>>

已知fibonacci数列:1,1,2,3,5,8,......,它...

f1=1; i=0;i

这个是用C写的。会要求输入一个整数,此时输入50即可。当然可以略作修改,只算F(50)。 #include int main() { int n, first = 0, second = 1, next, c; printf("Enter the number of terms\n"); scanf("%d",&n); printf("First %d terms of Fibo...

F(n)=F(n-1)+F(n-2)(n≥3,n∈N*) 所以F(20)=F(19)+F(18) =F(18)+F(17)+F(18) =F(18)+F(16)+F(15)+F(17)+F(16) =F(18)+F(17)+F(16)+F(16)+F(15) (整理后) =F(18)+F(17)+F(16)+F(15)+F(15)+F(14) =F(18)+F(17)+F(16)+F(15)+F(14)+F(14)+F(1...

修改一下max = cond+3; ======================== #include int fibonacci(int n) { if(n== 1 || n==2) { return 1; } else { return fibonacci(n-1) + fibonacci(n-2); } } int main() { int cond; int i = 1; int max; int val; printf("请输...

#include "stdio.h" int main() { int i,f,f1,f2; f1=f2=1; //前两项作为初始值 printf("%d %d ",f1,f2); for(i=3;i

程序如下F: >>clear n=input('please input n='); %输入前n项的n值.. for i=1:(n-2) a(1)=1;a(2)=1; a(i+2)=a(i+1)+a(i); end M=sum(a') 点回车运行 (本例中.n=20) please input n=20 得到结果:M=17710 不好意思..理解错误..上面程序是求前20项...

提供一个C的作参考。 #include "stdio.h"int fbnc(int n){ if(n==1 || n==2) return 1; return fbnc(n-1)+fbnc(n-2);}int main(void){ int i,k; for(k=0,i=1;i

function fabidd(num) a(1) = 1; a(2) = 1; for i=3:num a(i) = a(i-2)+a(i-1); if a(i)>50 break; end end

1. Private Sub Command1_Click()Dim a(30), i, j As Longa(1) = 1a(2) = 1For i = 3 To 30 a(i) = a(i - 2) + a(i - 1) For j = 2 To a(i) - 1 If a(i) Mod j = 0 Then Exit For Next If j = a(i) Then Print a(i);NextEnd Sub2. Private Sub C...

#include int main() {int a[20],n,i,s=2; a[0]=a[1]=1; printf("1 1 "); for(i=2;i

网站首页 | 网站地图
All rights reserved Powered by www.ksdf.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com