Primality Test | Set 1 ( Introduction and School Method ) | A school method based Javascript program to check if a number is prime ; Corner case ; Check from 2 to n - 1 ; Driver Program to test above function
function isPrime ( n ) { if ( n <= 1 ) return false ; for ( let i = 2 ; i < n ; i ++ ) if ( n % i == 0 ) return false ; return true ; } isPrime ( 11 ) ? document . write ( " " + " " ) : document . write ( " " + " " ) ; isPrime ( 15 ) ? document . write ( " " + " " ) : document . write ( " " + " " ) ;