Skip to content

Instantly share code, notes, and snippets.

@thmain
Last active May 27, 2018 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thmain/c258434e3a6830ff4ca0 to your computer and use it in GitHub Desktop.
Save thmain/c258434e3a6830ff4ca0 to your computer and use it in GitHub Desktop.
public class Fibonacci{
public static int fibDP(int x) {
int fib[] = new int[x + 1];
fib[0] = 0;
fib[1] = 1;
for (int i = 2; i < x + 1; i++) {
fib[i] = fib[i - 1] + fib[i - 2];
}
return fib[x];
}
public static void main(String[] args){
System.out.println(fibDP(10));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment