C#斐波那契数列方法

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace di3tishulie
 8 {
 9 class Program
10 {
11 static long ds = 0;
12 
13  
14 
15 static void Main(string[] args)
16 {
17 
18 long aa = ff(1, 1,2);
19 Console.WriteLine(aa);
20 Console.ReadKey();
21 
22 }
23 static long ff(long x, long y, int z)
24 {
25 long ds1 = ds;//int ds1 = ds;// 当为int长度时候,最高到46,1836311903
26 ds = x + y; 
27 z++;
28 if (z==50)//当z=5时候,是数列7项;第30项时,z==30-2=28,把z传递为2;
29 {
30 return ds;
31 }
32 if (z <=3)//当z传递-2时,条件改为-1
33 {
34 return ff(ds, y, z++);
35 }
36 else
37 {
38 return ff(ds, ds1, z++);
39 
40 }
41 
42 }
43 
44 }
45 }
原文地址:https://www.cnblogs.com/enych/p/7469792.html