If ceil and floor are equal the number is a perfect square
if ( Math . ceil ( Math . sqrt ( n ) ) == Math . floor ( Math . sqrt ( n ) ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; } }