Sap Labs Interview Question for Senior Software Development Engineers
- 0of 0 votes
A Fibonacci sequence is defined recursively by:- manojgct84 September 17, 2020 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.
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
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.
| Report Duplicate | Flag | PURGE
Sap Labs Senior Software Development Engineer Java
Interview Type: Written Test
Open Chat in New Window