Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. public static void fib(int n)
  2. {
  3. int neW = 1;
  4. int next = 1;
  5. int old = neW - next;
  6. while (neW <= n)
  7. {
  8. neW = next + old;
  9. old = next;
  10. next = neW;
  11. System.out.println(neW);
  12. }
  13.  
  14. }
  15.  
  16. public static void fib(int n)
  17. {
  18. int current = 0;
  19. int old = 1;
  20. int new = 0;
  21. for(int i = 0; i < n; i = i+1)
  22. {
  23. new = current + old;
  24. old = current;
  25. current = new;
  26. System.out.println(current);
  27. }
  28.  
  29. }
  30.  
  31. public static void fib(int b)
  32. {
  33. int n = 0;
  34. int neW = 1;
  35. int next = 1;
  36. int old = neW - next;
  37. while (n <= b)
  38. {
  39. System.out.println(neW);
  40. neW = next + old;
  41. old = next;
  42. next = neW;
  43. n++;
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement