Lucas Numbers | Recursive C / C ++ program to find n 'th Lucas number ; recursive function ; Base cases ; recurrence relation ; Driver Code
#include <stdio.h> NEW_LINE int lucas ( int n ) { if ( n == 0 ) return 2 ; if ( n == 1 ) return 1 ; return lucas ( n - 1 ) + lucas ( n - 2 ) ; } int main ( ) { int n = 9 ; printf ( " % d " , lucas ( n ) ) ; return 0 ; }