Limits 1s, 512 MB

Fibonacci sequence is a recursive sequence that depends on the following definition:

This is a companion discussion topic for the original entry at https://toph.co/p/mystery-of-fibonacci

Limits 1s, 512 MB

Fibonacci sequence is a recursive sequence that depends on the following definition:

This is a companion discussion topic for the original entry at https://toph.co/p/mystery-of-fibonacci

Why My code is causing Runtime Error…I have used memoization and my code can even handle more then the contrain values!

```
#define MAX_SIZE 1000005
#include<set>
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#include<climits>
#include<cstring>
#include<cmath>
#include<unordered_map>
#include<sstream>
using namespace std;
long long int term[1000000];
int fib(int n){
if (n <= 1)
return n;
if (term[n] != 0)
return term[n];
else {
term[n] = (fib(n - 1) + fib(n - 2))%1000000007;
return term[n];
}
}
int main(){
int n;
cin>>n;
cout<<fib(n);
}
```

I have added all the headers but couldn’t pasted that properly…