Check for possibility
if ( ans_pair . first == - 1 ) { document . write ( " " ) ; return ; } var a1 = ans_pair . first ; var a2 = ans_pair . second ; var r = a2 / a1 ; document . write ( " " ) ; for ( var i = 1 ; i <= n ; i ++ ) { var ai = parseInt ( a1 * Math . pow ( r , i - 1 ) ) ; document . write ( ai + " " ) ; } }