created lucas function to find nth value