Could someone help me to understand why is the output of written below problem is 21? Thanks in advanced.
The Skywalker Incursion problem from Dcoder Luke Skywalker is wandering across the desert of Tatooine in search of Obi-Wan Kenobi. Luke is following the footprints of Kenobi and soon happens to notice a pattern in them. The footprints are in a Lucas Sequence, i.e, the series made by distances between two consecutive footprints is Lucas Sequence(2,1,3,4,7,11,18...). After some time, much to Luke's disappointment, a dust storm erased all the footprints. He still believes the pattern of his movements should continue according to the Lucas Sequence but he is confused. You will be given the current position of Luke, tell him the next nearest number that belongs to the Lucas Sequence. The Lucas numbers may be defined as follows: L(x) = { 2 if x = 0; 1 if x = 1; L(x-2) + L(x-1) , otherwise } Input A single positive integer N. Output A single positive integer. Constraint 0 ≤ N ≤ 10^8 Sample Input 15 Sample Output 21