Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. static void Main(string[] args)
  2.         {
  3.             Console.WriteLine("До какого числа считать ряд Фибоначчи?");
  4.            
  5.             fibb();
  6.             Console.ReadLine();
  7.         }
  8.         static void fibb()
  9.         {
  10.            
  11.             int number = Convert.ToInt32(Console.ReadLine());
  12.             int perv = 1;
  13.             Console.Write("{0} ", perv);
  14.             int vtor = 1;
  15.             Console.Write("{0} ", vtor);
  16.             int sum = 0;
  17.             while (number >= sum)
  18.             {
  19.                 sum = perv + vtor;
  20.  
  21.                 Console.Write("{0} ", sum);
  22.  
  23.                 perv = vtor;
  24.                 vtor = sum;
  25.             }
  26.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement