Advertisement
Guest User

Untitled

a guest
Jan 20th, 2015
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 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 Fibonaci
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. System.Console.WriteLine("Is it Finobaci? Enter number:");
  14. int fib = int.Parse(Console.ReadLine());
  15. int a=0;
  16. int b=1;
  17. int c;
  18. int position=2;
  19. if (fib == 0)
  20. {
  21. Console.WriteLine("It is Fibonaci. At position: 1");
  22. }
  23. if (fib == 1)
  24. {
  25. Console.WriteLine("It is Fibonaci. At position: 2/3");
  26. }
  27. if (fib > 1)
  28. {
  29. do
  30. {
  31.  
  32. c = a + b;
  33. position++;
  34. if (c == fib)
  35. {
  36. Console.WriteLine("It is Fibonaci. At position:");
  37. Console.WriteLine(position);
  38. }
  39. if (c > fib)
  40. {
  41. Console.WriteLine("It is NOT Fibonaci.");
  42. }
  43. a = b;
  44. b = c;
  45. }
  46. while (c < fib);
  47. }
  48.  
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement