Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace FibonacciSeriesInCSharp
- {
- class Program
- {
- static void Main(string[] args)
- {
- int i, nOne = 0, nTwo = 1, next;
- Console.WriteLine("Enter a Number");
- int n = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Fibonacci Series are");
- for (i = 0; i < n; i++)
- {
- if (i<=1)
- {
- next = i;
- }
- else
- {
- next = nOne + nTwo;
- nOne = nTwo;
- nTwo = next;
- }
- Console.WriteLine(next);
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement