Skip to content

Instantly share code, notes, and snippets.

@ehgoodenough
Created July 11, 2012 16:57
Show Gist options
  • Save ehgoodenough/3091718 to your computer and use it in GitHub Desktop.
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.
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