Skip to content

Instantly share code, notes, and snippets.

@rsayers
Created January 16, 2010 21:47
Show Gist options
  • Save rsayers/279030 to your computer and use it in GitHub Desktop.
Save rsayers/279030 to your computer and use it in GitHub Desktop.
public class fib {
public static int fib(int n) {
if (n <= 1) {return n;}
return fib(n-1) + fib(n-2);
}
public static void main(String[] args) {
for (int i = 0; i < 36; i++)
System.out.println("n = " + i + " => " + fib(i));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment