Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void fib(int n)
- {
- int neW = 1;
- int next = 1;
- int old = neW - next;
- while (neW <= n)
- {
- neW = next + old;
- old = next;
- next = neW;
- System.out.println(neW);
- }
- }
- public static void fib(int n)
- {
- int current = 0;
- int old = 1;
- int new = 0;
- for(int i = 0; i < n; i = i+1)
- {
- new = current + old;
- old = current;
- current = new;
- System.out.println(current);
- }
- }
- public static void fib(int b)
- {
- int n = 0;
- int neW = 1;
- int next = 1;
- int old = neW - next;
- while (n <= b)
- {
- System.out.println(neW);
- neW = next + old;
- old = next;
- next = neW;
- n++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement