Factorize
Calculates the decomposition of a positive integer into primes.
Interface
#include <codecogs/maths/discrete/number_theory/factorize.h>
using namespace Maths::Discrete::Number_Theory;
Overview
Detailed Description...
Members of factor
CLASS METHOD
factorize
This functions calculates the unique factorization of a positive number into a product of primes raised to certain powers.
Example:
#include <codecogs/maths/discrete/number_theory/factorize.h>
#include <iostream>
int main()
{
std::vector<factor> result = Maths::Discrete::NumberTheory::factorize(123456);
std::cout << "The factorization of 123456 into primes is" << std::endl;
for (int i = 0; i < result.size(); i++)
std::cout << result[i].value << "^" << result[i].power << " ";
std::cout << std::endl;
return 0;
}
Output:
The factorization of 123456 into primes is
2^6 3^1 643^1
Returns
the prime factorization of n
Author
Lucian Bentea (August 2005)
This function's source code is only visible to registered users — documentation and the calculator above are free to use either way. Sign in to see it.