Skip to content

Instantly share code, notes, and snippets.

@reza-ryte-club
Last active August 29, 2015 14:19
Show Gist options
  • Save reza-ryte-club/c139aa7e2cdb3b84abb3 to your computer and use it in GitHub Desktop.
Save reza-ryte-club/c139aa7e2cdb3b84abb3 to your computer and use it in GitHub Desktop.
function checkIfPrime(number){
for( something = 2; something <= Math.sqrt(number); something++)
if( number % something == 0) return 0;
return 1;
}
function findPrimeFactors(number) {
//find prime numbers less than the number
for( i = Math.floor(number/2); i >=2 ; i--)
if ( number % i == 0)
if (checkIfPrime(i) == 1)return i;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment