MeetCode
Solve Linear Recurrence
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Run
Submit
Dark
Problem Statement
Solutions
Submissions
Solve Linear Recurrence
Hard
Computer Mathematics
Recurrences
28 views
Explanation
Complexity
Problem Statement
Given f0,f1 and f(n)=f(n-1)+2f(n-2), compute f(n).
Input Format
f0 f1 n.
Output Format
One integer.
Example
Input
0 1 5
Output
21
Constraints
0
Input / Output Format
Input Format
f0 f1 n.
Output Format
One integer.
Constraints
0
Examples
Input:
0 1 5
Output:
21
Example Solution (Public)
Computer Mathematics
Iterate from 2..n using recurrence, store last two values.
Official Solution Code
Wrap
Copy
Iterate from 2..n using recurrence, store last two values.
Please
login
to submit solutions.
Editor
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Test Cases
Output
Submission Result
Input
0 1 5
Expected Output
21
Compile Output
Error
Output
Please
login
to submit solutions.