Lucas numbers

The Lucas numbers L0,L1,L2,L_0,L_1,L_2,\ldots are closely related to the Fibonacci numbers. For any non-negative integer n0n\geq 0, the nnth Lucas number is defined as Ln={2ifn=0,1ifn=1,Ln1+Ln2ifn>1.L_n = \left\{ \begin{array}{ll} 2 & \mathrm{if} \;\; n=0,\\ 1 & \mathrm{if} \;\; n=1,\\ L_{n-1}+L_{n-2} & \mathrm{if} \;\; n>1. \end{array} \right.

Input

The input starts with an integer CC, the number of cases. On each of the following CC lines is a single integer nn which satisfies 0n300\leq n\leq 30.

Output

For each case nn, output the Lucas number LnL_n on a single line.

Problem information

Author: Anders Jonsson

Generation: 2026-01-25T14:27:34.817Z

© Jutge.org, 2006–2026.
https://jutge.org