Skip to content

Instantly share code, notes, and snippets.

@dalcon10028
Created January 31, 2020 06:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dalcon10028/339c3bcce9fbc797de636dc5e517c5cd to your computer and use it in GitHub Desktop.
Save dalcon10028/339c3bcce9fbc797de636dc5e517c5cd to your computer and use it in GitHub Desktop.
import java.util.*;
public class Main {
static long[] memo = new long[91];
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print(fibo(sc.nextInt()));
}
static long fibo(int n){
if (n<=1) return n;
if (memo[n]!=0) return memo[n];
memo[n] = fibo(n-1)+fibo(n-2);
return memo[n];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment