Given a number N find the sum of all the even valued terms in the fibonacci sequence less than or equal to N.

The first few terms of Fibonacci Numbers are, 1, 1, **2**, 3, 5, **8**, 13, 21, **34**, 55, 89, **144**, 233 ,… (Even numbers are highlighted).

**Input:**

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains the integer N.

**Output:**

Print the sum of all the even valued terms in the fibonacci sequence less than or equal to given N. Print the answer for each test case in a new line.

**Constraints:**

1<= T <=100

1<= N <=1000000

**Example:
Input:**

2

8

400

**Output:**

10

188

Author: sujnesh

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

preparecodinginterview_dot_com | 190 |

__murugan__ | 173 |

manvimahajan20 | 140 |

xiaoyan_yunche | 139 |

ShameekAgarwal | 116 |

preparecodinginterview_dot_com | 190 |

__murugan__ | 173 |

manvimahajan20 | 166 |

SoumyaKaushik | 146 |

arpit_anshuman | 140 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.