# Add the Fibonnaci Sequence to the Lucas Sequence [duplicate]

Background of Lucas Numbers

The French mathematician, Edouard Lucas (1842-1891), who gave the name to the Fibonacci Numbers, found a similar series occurs often when he was investigating Fibonacci number patterns.

The Fibonacci rule of adding the latest two to get the next is kept, but here we start from 2 and 1 (in this order) instead of 0 and 1 for the (ordinary) Fibonacci numbers. The series, called the Lucas Numbers after him, is defined as follows: where we write its members as Ln, for Lucas:

Challenge

Input

0 < x < ∞
The input will be a positive integer starting at 0.

Output

The output must be a positive integer.

What to do?

Add the Fibonacci numbers to the Lucas numbers.
You will input the index.
The output will be the addition of the Lucas and Fibonacci numbers.

Fibonnaci formula:

F(0) = 0,
F(1) = 1,
F(n) = F(n-1) + F(n-2)

Lucas formula:

L(0) = 2,
L(1) = 1,
L(n) = L(n-1) + L(n-2)

Who wins?

Standard Code-Golf rules apply, so the shortest answer in bytes wins.

Test-cases

A(0) = 2
A(1) = 2
A(5) = 16
A(10) = 178
A(19) = 13,530
A(25) = 242,786

• This is just twice the Fibonacci numbers, with a different offset. (L[n] = F[n–1] + F[n+1], so L[n] + F[n] = 2F[n+1].) I'm tempted to call it a duplicate.
– lynn
Commented Nov 27, 2016 at 12:20
• @Belfield I'm not sure I follow. This is just 2F[n+1]. The Mathematica answer 2Fibonacci[#+1]& solves the challenge. Commented Nov 27, 2016 at 12:37
• Yes, didnt see that @Lynn Commented Nov 27, 2016 at 12:56

A(n){return n<2?2:A(n-1)+A(n-2);}

• Why is there no int? Commented Nov 27, 2016 at 12:19