Check for possibility
if ( ans_pair . first == - 1 ) { System . out . print ( " Not ▁ possible " ) ; return ; } double a1 = ans_pair . first ; double a2 = ans_pair . second ; double r = a2 / a1 ; System . out . print ( "The resultant sequence is:NEW_LINE"); for ( int i = 1 ; i <= n ; i ++ ) { int ai = ( int ) ( a1 * Math . pow ( r , i - 1 ) ) ; System . out . print ( ai + " ▁ " ) ; } }