I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
get GPL
COST (GBP)
this unit 0.50
sub units 0.10
+
0

Factorize Direct

Calculates the decomposition of a positive integer into primes.
Controller: CodeCogs

Dependents

Info

Interface

C++

Factorize Direct

 
std::vector<factor>factorize_directunsignedn )
This functions calculates the unique factorization of a positive number into a product of primes raised to different powers. It uses the Maths/NumberTheory/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 Maths/NumberTheory/Primes component.

Warning

While using this component, one cannot also include the Maths/NumberTheory/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

the prime factorization of n

Authors

Lucian Bentea (August 2005)
Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.


Other Documentation

Detailed Description...
Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.