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 ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Enter a whole number");
- uint n = uint.Parse(Console.ReadLine());
- int first = 0;
- int second = 1;
- int third = 0;
- int sum = 0;
- for (int i = 0; i < n - 1; i++)
- {
- first = second;
- second = third;
- third = first + second;
- sum = sum + third;
- }
- Console.WriteLine("\nsum of first {0} number in Fibonacci's sequence = {1}\n\n", n, sum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement