Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- class SquareofStars
- {
- static void Main(string[] args)
- {
- //Problem 10.* Fibonacci Numbers
- int n = int.Parse(Console.ReadLine());
- if (n == 0)
- {
- Console.WriteLine("Invalid input");
- }
- else if (n == 1)
- {
- Console.WriteLine(0);
- return;
- }
- int x1 = 0;
- int x2 = 1;
- Console.Write("{0} {1} ", x1, x2);
- int x3;
- for (int i = 2; i <= n; i++)
- {
- x3 = x1 + x2;
- if (i!=n)
- {
- Console.Write(" {0},", x3);
- }
- else if (i==n)
- {
- Console.Write(" {0}", x3);
- }
- x1 = x2;
- x2 = x3;
- }
- Console.WriteLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement