Created
March 6, 2017 08:00
-
-
Save JackDraak/0a57be7174cb154faae1dda181d02316 to your computer and use it in GitHub Desktop.
recursive method
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
void GetPrimeFactors(uint64_t number) | |
{ | |
if (number == 2) | |
{ | |
primeFactors.push_back(number); | |
return; | |
} | |
int max = floor(sqrt(number)); | |
uint64_t factor; | |
for (uint64_t n = max; n > 1; n--) | |
{ | |
if (IsPrime(n)) | |
{ | |
int remainder = number % n; | |
GetPrimeFactors(remainder); | |
primeFactors.push_back(n); | |
} | |
} | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment