Skip to content

Instantly share code, notes, and snippets.

@Lablnet Lablnet/prime.php
Created Dec 30, 2018

What would you like to do?
Determine whether the given number is prime or not
function isPrime($n)
for ($i = 2; $i < $n ; $i++) {
if ($n % $i === 0){
return false;
return true;
var_dump(isPrime(9)); // bool(false)
var_dump(isPrime(11)); // bool(true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.