Factorize_Direct
Calculates the decomposition of a positive integer into primes.
You're viewing an older version of this page (#85). View the current version.
Interface
#include <codecogs/maths/discrete/number_theory/factorize_direct.h>
using namespace Maths::Discrete::Number_Theory;
Overview
Detailed Description...
Members of factor
CLASS METHOD
factorize_direct
This functions calculates the unique factorization of a positive number into a product of primes raised to different powers. It uses the Primes function to directly find a prime number and test the division of n against it. This proves to be faster than the other prime decomposition function; the only limitation is the maximum number of primes stored within the Primes component.
While using this component, one cannot also include the Factorize component. This will generate a compiler error.
Example:
#include <codecogs/maths/discrete/number_theory/factorize_direct.h>
#include <iostream>
int main()
{
std::vector<factor> result = Maths::NumberTheory::factorize_direct(65435);
std::cout << "The factorization of 65435 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 65435 into primes is
5^1 23^1 569^1
Returns
Lucian Bentea (August 2005)