Re: Easy test of surrogate factoring

From: Marcel Martin (mm_at_nowhere.net)
Date: 02/19/05


Date: Sat, 19 Feb 2005 08:54:34 +0100

Décio Luiz Gazzoni Filho wrote:

> Matt Gutting wrote:
>
>><snip>
>>
>>Heck, James, *I* can write a program to factor an RSA number. How about
>>this?
>>
>>int M;
>>M = //insert the RSA number here
>>for (int i=2; i<=sqrt(M);i++) {
>> if (M % i = 0) {
>> cout << i << " is a factor of " << M;
>> }
>>}
>>
>
> I don't think your program works, because a typical RSA number won't fit in
> an integer. Try this (if you have GMP and the C++ class interface):
>
> #include <iostream>
> #include <gmpxx.h>
>
> int main()
> {
> mpz_class M(/*insert RSA number here between quotes*/);
> for(mpz_class p=2; p<=sqrt(M); mpz_nextprime(p.get_mpz_t(),p.get_mpz_t())
> if(mpz_divisible_p(M.get_mpz_t(),p.get_mpz_t())
> {
> std::cout << p << " is a factor of " << M << std::endl;
> break;
> }
> return 0;
> }
>
> I included a few optimizations, although a key would be to try backwards
> from sqrt(M), because any given factors will be closer to sqrt(M) than 2.

Not sure. There are as much integers between 1 and 2^k
than between 2^k + 1 and 2^(k+1).
So, if (BinarySize(Sqrt) - BinarySize(Factor)) > 1 holds
then Factor is closer to 2 than to Sqrt.

mm



Relevant Pages

  • Re: Easy test of surrogate factoring
    ... >> I don't think your program works, because a typical RSA number won't fit ... >> int main ... >> I included a few optimizations, although a key would be to try backwards ... because any given factors will be closer to sqrtthan 2. ...
    (sci.crypt)
  • Re: Easy test of surrogate factoring
    ... Matt Gutting wrote: ... I don't think your program works, because a typical RSA number won't fit in ... int main ...
    (sci.math)
  • Re: Easy test of surrogate factoring
    ... Matt Gutting wrote: ... I don't think your program works, because a typical RSA number won't fit in ... int main ...
    (sci.crypt)
  • Re: the whole Vickers car confiscation thing
    ... > have to fit at the same time, why should they design the car to ... If I were NASCAR, I'd be giving them closer and closer ... inspections. ...
    (rec.autos.sport.nascar.moderated)
  • Re: linear regression - inconsistent results
    ... When we evaluate the red line for the y values you used to fit the line, ... seems to be a rough approximation to the vertical line around x = 0.014. ... the black x's and the red +'s are much closer to one ...
    (comp.soft-sys.matlab)