CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2007
    Location
    Mars NASA Station
    Posts
    1,436

    Smile Prime Factorization

    Hello to all friends, how to code a prime factorization. Any simple explanation ?

    Thanks for your help.
    Thanks for your help.

  2. #2
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Prime Factorization

    Quote Originally Posted by Peter_APIIT View Post
    Hello to all friends, how to code a prime factorization. Any simple explanation ?

    Thanks for your help.
    Google is your friend...plenty of good examples...plus the text book(s) from your classes may have some implementations, as this is often a problem in a first semester course.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  3. #3
    Join Date
    Apr 2007
    Location
    Mars NASA Station
    Posts
    1,436

    Re: Prime Factorization

    My class does not covers this and google does not return any concrete result.

    I just need a simple explanation.

    Thanks.
    Thanks for your help.

  4. #4
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Prime Factorization

    Quote Originally Posted by Peter_APIIT View Post
    My class does not covers this and google does not return any concrete result.

    I just need a simple explanation.

    Thanks.
    4th hit on google. http://en.wikipedia.org/wiki/Prime_factor
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  5. #5
    Join Date
    Apr 2007
    Location
    Mars NASA Station
    Posts
    1,436

    Re: Prime Factorization

    Anyone know Quadratic Sieve Algorithm ?
    Thanks for your help.

  6. #6
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Prime Factorization

    Quote Originally Posted by Peter_APIIT View Post
    Anyone know Quadratic Sieve Algorithm ?
    WHY do you refuse to do research???

    Google provides immediate results.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  7. #7
    Join Date
    Apr 2007
    Location
    Mars NASA Station
    Posts
    1,436

    Re: Prime Factorization

    I did my research but i not understand the algorithm.

    I have found this.

    Quadratic Sieve factoring algorithm:

    to factor n:

    1. Select a set of prime numbers called the factor base.
    (Selecting the factor base requires further explanation.)

    2. For each integer f close to the square root of n,
    try to factor (f^2)-n(mod n) with the primes in the factor base.
    ("Close to" is defined as an arbitrary range.)

    3. If any or all of the primes in the factor base are factors
    of (f^2)-n(mod n), save f.

    4. Choose several of the saved f's such that when their squares
    are multiplied together, the prime factors of the product(mod n)
    all have even exponents.

    5. Call the product of the f's x.

    6. Call the square root of the product of the prime factors y.

    7. Then, gcd(x+y, n) and gcd(x-y, n) are factors of n.

    -----------------------------------------------------------------------------

    Example:

    to factor n=4633:

    1. factor base = {2, 3, 5}

    2. sqrt(4633) = 68.xxx, so f's "close to" 68 are, say, 38 to 98

    3. For f's ((38, 98)^2) - 4633(mod n), the following have 2, 3 or 5
    as prime factors: 59, 67, 68, 69, 85, 96

    4. (68 * 69 * 96)^2(mod n) = 2^8 * 3^2 * 5^2 (the exponents are all even).

    5. x = sqrt((68 * 69 * 96)^2(mod n));
    y = sqrt(2^8 * 3^2 * 5^2)

    6. x = (68 * 69 * 96) = 450432; y = ((2^4) * 3 * 5) = 240

    7. gcd(450432+240, 4633) = 41; gcd(450432-240, 4633) = 113

    8. 4633 = 41 * 113
    Why he say 38 to 98 in 2?

    I hope someone can clear myth.
    Thanks.
    Thanks for your help.

  8. #8
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Prime Factorization

    Quote Originally Posted by Peter_APIIT View Post
    I did my research but i not understand the algorithm.

    I have found this.



    Why he say 38 to 98 in 2?

    I hope someone can clear myth.
    Thanks.
    Look at #2...
    2. For each integer f close to the square root of n,
    try to factor (f^2)-n(mod n) with the primes in the factor base.
    ("Close to" is defined as an arbitrary range.)
    He picked 30 as the definition of "close". No mystery.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured