Lucas Numbers | Iterative function ; declaring base values for positions 0 and 1 ; generating number ; Driver Code
def lucas ( n ) : NEW_LINE INDENT a = 2 NEW_LINE b = 1 NEW_LINE if ( n == 0 ) : NEW_LINE INDENT return a NEW_LINE DEDENT for i in range ( 2 , n + 1 ) : NEW_LINE INDENT c = a + b NEW_LINE a = b NEW_LINE b = c NEW_LINE DEDENT return b NEW_LINE DEDENT n = 9 NEW_LINE print ( lucas ( n ) ) NEW_LINE