Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp16
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = Int32.Parse(Console.ReadLine());
- int a = 0;
- int b = 1;
- int summa = 0;
- // In N steps compute Fibonacci sequence iteratively.
- while (n >= a && n >= b)
- {
- int temp = a;
- a = b;
- b = temp + b;
- Console.WriteLine(a);
- summa += a;
- }
- Console.WriteLine("Summa: " + summa);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement