Created
July 11, 2012 16:57
-
-
Save ehgoodenough/3091718 to your computer and use it in GitHub Desktop.
Just your genericly recursive fibonacci function; nothing is concatenated, obfuscated or optimized. It's written in java to use in various assignments.
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 fibonacci | |
{ | |
public static void main(String[] args) | |
{ | |
System.out.println(fibonacciValue(5)); | |
} | |
public static int fibonacciValue(int fibonacciIndex) | |
{ | |
if(fibonacciIndex < 2) {return 1;} | |
return fibonacciValue(fibonacciIndex - 2) + fibonacciValue(fibonacciIndex - 1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment