Last active
November 9, 2015 17:36
-
-
Save fmamud/c7a0127b6a0e5c74506f to your computer and use it in GitHub Desktop.
Fibonacci with infinite loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FibInfiniteLoop { | |
static void fib(long n) { | |
int a = 0, b = 1; | |
while (a < n) { | |
System.out.printf("%d %n", a); | |
a = b; | |
b = a + b; | |
} | |
} | |
public static void main(String[] args) { | |
fib(1000000000000L); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment