Geeks Sum
Submissions: 394   Accuracy:

46.45%

  Max. Score:

100

Given a positive integer n. Your task is to print first n Fibonacci terms and their Geeks Sum.

Geeks Sum : Sum of Fibonacci terms present at prime index (0 based indexing).

Input : First line of input conatins number of testcases T, and next T lines contains value of n (numbers of Fibonacci terms).
Output : For each testcase, print the first n Fibonacci terms in first line and the Geeks Sum in next line.

Constraints :
1 <= T <= 10
3 <= n <= 45

Example :
Input :
2
5
10

Output :
0 1 1 2 3
3
0 1 1 2 3 5 8 13 21 34
21

Explanation :
Testcase 2 : First 10 Fibonacci terms are: 0 1 1 2 3 5 8 13 21 34.
Geeks Sum = 1 + 2 + 5 + 13 = 21.


to report an issue on this page.