Re: 2^64 - 39 ...

2015-09-09 Thread Michal Bozon
> ... > Michael > you have won! > > --- /usr/src/games/factor/factor.c Wed Oct 28 00:59:24 2009 > +++ factor.cTue Sep 8 20:06:44 2015 > @@ -192,6 +192,19 @@ pr_fact(u_int64_t val) /* Factor this value. > */ > (void)putchar('\n'); > } > > +static u_int32_t > +i

Re: 2^64 - 39 ...

2015-09-08 Thread Michael Warmuth-Uhl
On 09/08/15 08:03, Otto Moerbeek wrote: > My bet would be Newton iteration, which should converge faster than > binary search. ping(8) has an implementation of integer sqrt. > > BTW, long double won't fix the problem on al platforms since it is not > guaranteed to be longer than double. Newton is

Re: 2^64 - 39 ...

2015-09-08 Thread Christian Weisgerber
On 2015-09-07, Otto Moerbeek wrote: > The game is to fix the bugs FWIW, FreeBSD has changed factor(6) to use libcrypto's BN functions. -- Christian "naddy" Weisgerber na...@mips.inka.de

Re: 2^64 - 39 ...

2015-09-08 Thread Daniel Boulet
Here’s a function that computes unsigned long square roots using Newton’s method. I believe that I have tested it quite carefully and am quite confident that it works correctly. It returns the unsigned long exact square root value if there is one. Otherwise, it returns the closest unsigned lo

Re: 2^64 - 39 ...

2015-09-07 Thread Otto Moerbeek
On Mon, Sep 07, 2015 at 06:20:02PM -0400, Raul Miller wrote: > On Mon, Sep 7, 2015 at 6:03 PM, Ted Unangst wrote: > > Michael Warmuth-Uhl wrote: > >> On 2015-09-07, Otto Moerbeek wrote: > >> It seems to fix the issues on amd64, but I'm not sure if the accuracy of > >> long double and sqrtl is gua

Re: 2^64 - 39 ...

2015-09-07 Thread Michal Bozon
there's more.. * worst case is 18446744030759878681, which is previous_prime(sqrt(2^64))^2, which is 4294967291^2 * _smallest_ OpenBSD composite prime seems to be 4295360521, which is 65539^2 Michal Bozon

Re: 2^64 - 39 ...

2015-09-07 Thread Raul Miller
On Mon, Sep 7, 2015 at 6:03 PM, Ted Unangst wrote: > Michael Warmuth-Uhl wrote: >> On 2015-09-07, Otto Moerbeek wrote: >> It seems to fix the issues on amd64, but I'm not sure if the accuracy of >> long double and sqrtl is guaranteed to be enough in general. > > using floating point seems suspect.

Re: 2^64 - 39 ...

2015-09-07 Thread Ted Unangst
Michael Warmuth-Uhl wrote: > Hello, > > On 2015-09-07, Otto Moerbeek wrote: > > The game is to fix the bugs > > Below is my attempt to play this game. > > It seems to fix the issues on amd64, but I'm not sure if the accuracy of > long double and sqrtl is guaranteed to be enough in general. usin

Re: 2^64 - 39 ...

2015-09-07 Thread Michael Warmuth-Uhl
Hello, On 2015-09-07, Otto Moerbeek wrote: > The game is to fix the bugs Below is my attempt to play this game. It seems to fix the issues on amd64, but I'm not sure if the accuracy of long double and sqrtl is guaranteed to be enough in general. Regards, Michael --- /usr/src/games/factor/fact

Re: 2^64 - 39 ...

2015-09-07 Thread Otto Moerbeek
On Mon, Sep 07, 2015 at 06:23:49PM +0200, Michal Bozon wrote: > .. i was wondering before, why *bin/factor is in games, now i get it. > Very nice observation! > > Another factor game fake primes: > > 18446744073709551503 == 2^64 - 113 == 119026343 * 154980348121 > 18446744073709551499 == 2^64 -

Re: 2^64 - 39 ...

2015-09-07 Thread Michal Bozon
.. i was wondering before, why *bin/factor is in games, now i get it. Very nice observation! Another factor game fake primes: 18446744073709551503 == 2^64 - 113 == 119026343 * 154980348121 18446744073709551499 == 2^64 - 117 == 363269 * 50779846542671 18446744073709551491 == 2^64 - 125 == 31578160