Created
January 31, 2020 06:58
-
-
Save dalcon10028/339c3bcce9fbc797de636dc5e517c5cd to your computer and use it in GitHub Desktop.
This file contains 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
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