Skip to content

Instantly share code, notes, and snippets.

@fmamud
Last active November 9, 2015 17:36
Show Gist options
  • Save fmamud/c7a0127b6a0e5c74506f to your computer and use it in GitHub Desktop.
Save fmamud/c7a0127b6a0e5c74506f to your computer and use it in GitHub Desktop.
Fibonacci with infinite loop
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