Lucas numbers X23272


Statement
 

pdf   zip

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.

Public test cases
  • Input

    4
    0
    1
    5
    10
    

    Output

    2
    1
    11
    123
    
  • Information
    Author
    Anders Jonsson
    Language
    English
    Official solutions
    C++
    User solutions
    C++