Question: How would you solve this in C++? A Fibonacci-like sequence is a sequence of integers a 1 , a 2 , ... for which a

How would you solve this in C++? A Fibonacci-like sequence is a sequence of integers a1, a2, ... for which an = an-1+an-2 for all n > 2. You are given the first two elements of the sequence a1 and a2, and the 1-based index n. Output the n-th element of the sequence.

The input data consists of a single line which contains integers a1, a2 and n separated by single spaces. 0 < a1, a2, n < 10.

Example

input

1 2 3

output

3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!