Finding Fibonacci sequence in C#. [Project Euler Exercise]

后端 未结 9 2271
后悔当初
后悔当初 2021-02-06 19:22

I\'m having some trouble with this problem in Project Euler.

Here\'s what the question asks:

Each new term in the Fibonacci sequence is generated by adding t

9条回答
  •  伪装坚强ぢ
    2021-02-06 19:56

         // count(user input) of Fibonacci numbers   
            int[] array = new int[20];
            array[0] = 0;
            array[1] = 1;
    
            Console.WriteLine(array[0] + "\n" + array[1]); 
    
            for (int i = 2; i < 20; i++)
            {
                array[i] = array[i - 1] + array[i - 2];
                Console.WriteLine(array[i]); 
            }
    

提交回复
热议问题