Skip to content

Instantly share code, notes, and snippets.

@philopaterwaheed
Last active February 2, 2024 07:27
Show Gist options
  • Save philopaterwaheed/631d30f8e5a214dbf5230de23e95dd09 to your computer and use it in GitHub Desktop.
Save philopaterwaheed/631d30f8e5a214dbf5230de23e95dd09 to your computer and use it in GitHub Desktop.
- Prime factorization is the process of finding the prime factors of a given number `n`
vector <pair <long long , int > > pri (long long n ) {
vector <pair <long long , int > > f ;
for ( long long d = 2 ; d *d <= n ; d++ ) {
int p = 0 ;
while (n % d == 0 ) {
n/= d;
p++ ;
}
if (p)
f.push_back ({d,p});
}
if (n>1)
f.push_back({n,1});
return f ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment