Insert all lucas numbers below max to the set a and b are first two elements of the Lucas sequence
HashSet < Integer > s = new HashSet < > ( ) ; int a = 2 , b = 1 ; s . add ( a ) ; s . add ( b ) ; while ( b < max ) { int c = a + b ; a = b ; b = c ; s . add ( b ) ; } for ( int i = 0 ; i < n ; i ++ ) {