Skip to content

Instantly share code, notes, and snippets.

@ik11235
Created December 28, 2014 13:45
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 ik11235/a42d9604fac2ff01d3ec to your computer and use it in GitHub Desktop.
Save ik11235/a42d9604fac2ff01d3ec to your computer and use it in GitHub Desktop.
class TheKingsFactorization {
public:
vector<long long> getVector(long long N, vector<long long> primes) {
for (int i=0; i<primes.size() ;i++) {
N/=primes[i];
}
for (int n=2; n<1000000&&N>1; n++) {
if(N%n==0)
{
primes.push_back(n);
N/=n;
n--;
}
}
if(N>1)
primes.push_back(N);
sort(primes.begin(),primes.end());
return primes;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment