Skip to content

Instantly share code, notes, and snippets.

@sdball
Created December 13, 2010 18:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save sdball/739353 to your computer and use it in GitHub Desktop.
Calculates arbitrary points in the fibonacci sequence using recursion. This is actually salesforce Apex code, not java.
// this is, obviously, just an apex exploration
// i.e. horribly inefficient
Integer fib(Integer n) {
if (n <= 1) return 1; else return fib(n-1) + fib(n-2);
}
for (Integer i=0; i<=12; i++) {
System.debug(fib(i));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment