Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class FibonacciNumbers
- {
- static void Main()
- {
- Console.WriteLine("How many numbers of the Fibonacci sequence would you like me to print?");
- int count = int.Parse(Console.ReadLine());
- for (int i = 0; i < count; i++)
- {
- Console.Write(Fibonacci(i) + " ");
- }
- Console.WriteLine();
- Console.ReadLine();
- }
- public static int Fibonacci(int numbers)
- {
- int a = 0;
- int b = 1;
- for (int i = 0; i < numbers; i++)
- {
- int temp = a;
- a = b;
- b = temp + b;
- }
- return a;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment