summaryrefslogtreecommitdiff
path: root/math/factor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'math/factor.cpp')
-rw-r--r--math/factor.cpp20
1 files changed, 0 insertions, 20 deletions
diff --git a/math/factor.cpp b/math/factor.cpp
deleted file mode 100644
index 621d057..0000000
--- a/math/factor.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-typedef pair<int,int> ii;
-//Factorize a number n in its prime factors
-//Call primeSieve-method before with N > sqrt(n)
-//Return: Returns a vector of pairs, where the first entry in the pair is
-//the prime factor p and the second counts how many times p divides n
-vector<ii> factorize(ll n) {
- vector<ii> fact; ll num = n, i = 0, c = 0;
- while(num != 1) {
- if(num % primes[i] == 0) {
- c++; num /= primes[i];
- } else {
- if(c > 0)
- fact.push_back(make_pair(primes[i],c));
- i++; c = 0;
- if(primes[i]*primes[i] > num) break;
- }
- }
- if(num != 1) fact.push_back(make_pair(num,c+1));
- return fact;
-} \ No newline at end of file