Advertisement
Guest User

Untitled

a guest
May 21st, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp16
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int n = Int32.Parse(Console.ReadLine());
  10. int a = 0;
  11. int b = 1;
  12. int summa = 0;
  13. // In N steps compute Fibonacci sequence iteratively.
  14. while (n >= a && n >= b)
  15. {
  16. int temp = a;
  17. a = b;
  18. b = temp + b;
  19. Console.WriteLine(a);
  20. summa += a;
  21. }
  22. Console.WriteLine("Summa: " + summa);
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement