Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@shubhamjain
Created April 12, 2019 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shubhamjain/e6d1105e6fa775a8b7d01e895ef7a4b0 to your computer and use it in GitHub Desktop.
Save shubhamjain/e6d1105e6fa775a8b7d01e895ef7a4b0 to your computer and use it in GitHub Desktop.
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