Last active
August 29, 2015 14:19
-
-
Save reza-ryte-club/c139aa7e2cdb3b84abb3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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