## manojgct84

BAN USER- 0of 0 votes

AnswersA Fibonacci sequence is defined recursively by:

- manojgct84 in India for Senior Software Engineer

F0 = 0

F1 = 1

Fn = Fn − 1 + Fn − 2, for integer n > 1.

One way of generalizing the Fibonacci sequence is by starting with any pair of numbers and extending to negative values of n.

Given two terms of a generalized Fibonacci sequence Fp and Fq, their positions p and q respectively and a position r, find Fr.

Input Format

The first line of the input contains an integer t denoting the number of test cases.

Each test case contains three lines.

First line of each test case contains two space separated integers p and Fp

Second line contains two space separated integers q and Fq

Third line contains an integer r

Output Format

For each test case, print Fr which is the term of the sequence at position r.

If Fr is not an integer, represent it as an irreducible fraction in the form a/b where b > 0.

Sample Input

0 1

6 13

10

3 65

6 315

-10

0 11

1 -6

2

9 36

15 646

-5

11 72

20 5473

6

Sample Output

89

4620

5

-1/4

13/2| Report Duplicate | Flag | PURGE

Sap Labs Senior Software Development Engineer Java - -1of 1 vote

AnswersYou are given a series of arithmetic equations as a string, such as:

- manojgct84 in India

y = x + 1

5 = x + 3

10 = z + y + 2

The equations use addition only and are separated by newlines. Return a mapping of all variables to their values. If it's not possible, then return null. In this example, you should return:

{

x: 2,

y: 3,

z: 5

}| Report Duplicate | Flag | PURGE

Google Software Engineer Problem Solving

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window