Skip to content

Instantly share code, notes, and snippets.

@shubhamjain
Created April 12, 2019 15:13
Embed
What would you like to do?
Google Sheets custom formula to check for primality
/**
* @customfunction
*/
function ISPRIME(number) {
for (var i = 2; i <= Math.sqrt (number); i++) {
if(number % i === 0) {
return false;
}
}
return number > 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment