Advertisement
GraionDilach

Fibonacci

Oct 10th, 2011
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication5
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             Console.WriteLine("Fibonacci - sorozat");
  13.             int a = 1, b = 1;
  14.             Console.WriteLine("Induló értékek: " + a + " " + b);
  15.             for (int i=1; a+b<=40000; i++){
  16.                 if (i % 2 == 0)
  17.                 {
  18.                     a += b;
  19.                     Console.Write("{0,6}", a);
  20.  
  21.                 }
  22.                 else
  23.                 {
  24.                     b += a;
  25.                     Console.Write("{0,6}", b);
  26.                 }
  27.  
  28.                 if (i % 5 == 0)
  29.                 {
  30.                     Console.Write("\n");
  31.                 }
  32.  
  33.             }
  34.  
  35.             Console.WriteLine();
  36.             Console.ReadLine();
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement