1// Function that returns a vector containing all the prime factors of n (25 --> 5, 5)
2vector<long long> prime_factorisation(long long n)
3{
4 //spf is smallest prime factor
5 map<long long, long long> spf;
6 vector<long long> ans(0);
7 for(long long i = 2; i <= n; i++) spf[i] = i;
8
9 for (long long i = 2; i <= n; i++)
10 if (spf[i] == i)
11 for (long long j = i * i; j <= n; j += i)
12 if (spf[j] == j)
13 spf[j] = i;
14
15 while (n != 1)
16 {
17 ans.push_back(spf[n]);
18 n /= spf[n];
19 }
20 return ans;
21}