Pabl0o0

Untitled

Oct 29th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp4
  8. {
  9. class Program
  10.  
  11. {
  12.  
  13. public static void Fibonacci(int x, int y, int n)
  14. {
  15.  
  16.  
  17. int b = x + 1;
  18. Console.WriteLine(n + " kolejnych liczb ciągu Fibonacciego od liczby x = " + x);
  19. for (int i = 0; i < n; i++)
  20. {
  21. int temp = x;
  22. x = b;
  23. b = temp + b;
  24. Console.WriteLine(x);
  25. }
  26.  
  27.  
  28. int a = y + 1;
  29. Console.WriteLine(n + " kolejnych liczb ciągu Fibonacciego od liczby y = " + y);
  30. for (int i = 0; i < n; i++)
  31. {
  32. int temp = y;
  33. y = a;
  34. a = temp + a;
  35. Console.WriteLine(y);
  36. }
  37. }
  38.  
  39. public static void Main (String[] args)
  40. {
  41. int n;
  42. Console.WriteLine("Podaj liczbę n: ");
  43. n = int.Parse(Console.ReadLine());
  44.  
  45. int x;
  46. Console.WriteLine("Podaj liczbę x: ");
  47. x = int.Parse(Console.ReadLine());
  48.  
  49. int y;
  50. Console.WriteLine("Podaj liczbę y: ");
  51. y = int.Parse(Console.ReadLine());
  52.  
  53. Fibonacci(x, y, n);
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment