Lucas numbers X23272


Statement
 

pdf   zip

html

The Lucas numbers L0,L1,L2,… are closely related to the Fibonacci numbers. For any non-negative integer n≥ 0, the nth Lucas number is defined as

Ln = 



2if    n=0,
1if    n=1,
Ln−1+Ln−2if    n>1.

Input

The input starts with an integer C, the number of cases. On each of the following C lines is a single integer n which satisfies 0≤ n≤ 30.

Output

For each case n, output the Lucas number Ln 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++