Skip to content

Instantly share code, notes, and snippets.

@reza-rahman-rx
Last active August 29, 2015 14:19
Show Gist options
  • Select an option

  • Save reza-rahman-rx/c139aa7e2cdb3b84abb3 to your computer and use it in GitHub Desktop.

Select an option

Save reza-rahman-rx/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