public
Last active

Calculates arbitrary points in the fibonacci sequence using recursion. This is actually salesforce Apex code, not java.

  • Download Gist
apex_fib.apex.java
Java
1 2 3 4 5 6 7 8 9
// 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));
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.