My Fibonacci
Practice
3 (94 votes)
Mathematics
Open
Approved
Easy
Problem
85% Success 6705 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Many of you know the famous Fibonacci sequence F:
- F[1] = 1
- F[2] = 1
- F[i] = F[i - 1] + F[i - 2] for i > 2
Thus each number in sequence is a sum of two previous numbers except two first which are define as 1.
You've decided to create you own Fibonacci sequence. It's very similar to the one described above, but the first two numbers now are arbitrary non-negative integers A and B ( F[1] = A and F[2] = B ). Now you want to compute the N-th number in your sequence.
Input
The only line contains 3 space-separated integers A, B, N.
Output
Output one integer - the N-th number in your sequence.
Constraints
- 0 < A, B, N <= 10
Submissions
Please login to view your submissions
Similar Problems
Points:20
4 votes
Tags:
Special NumbersCountingImplementationMath BasicBasic ProgrammingBasic MathBasics of ImplementationSieveMath
Points:20
155 votes
Tags:
MathematicsLucky-DigitEasySimple-math
Points:20
21 votes
Tags:
Bit manipulationBasic ProgrammingApprovedEasyBit manipulation
Editorial