Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

primes generates not-primes #3

Open
ghost opened this issue Oct 18, 2016 · 1 comment
Open

primes generates not-primes #3

ghost opened this issue Oct 18, 2016 · 1 comment

Comments

@ghost
Copy link

ghost commented Oct 18, 2016

I'm using primes on 64bit system, and when it's working on values above 2^32, it generates numbers that are not really primes.

It was reported to ubuntu: https://bugs.launchpad.net/ubuntu/+source/bsdgames/+bug/725367 - but this happened in 2012, and so far it wasn't fixed.

How to test it:

=$ for p in {31..62}; do echo -n "$p : "; bc <<< "x=2^$p;x;x+50000" | xargs primes | xargs -n1 factor | awk 'NF>2' | wc -l; done
31 : 0
32 : 0
33 : 132
34 : 233
35 : 372
36 : 413
37 : 522
38 : 612
39 : 665
40 : 732
41 : 753
42 : 787
43 : 912
44 : 926
45 : 965
46 : 987
47 : 1005
48 : 1017
49 : 1087
50 : 1089
51 : 1134
52 : 1195
53 : 1204
54 : 1212
55 : 1240
56 : 1194
57 : 1243
58 : 1277
59 : 1294
60 : 1364
61 : 1416
62 : 1331

primes is a command from coreutils.

Example prime:

=$ primes 35198908481059600 35198908481059602

  35198908481059601

=$ factor 35198908481059601
35198908481059601: 181399 405277 478787
@shlomif
Copy link

shlomif commented Oct 24, 2017

Hi!

I ran into this problem today:

shlomif[ProjEuler]:~/progs/riddles/project-euler/git/project-euler/3$ primes 90000000000000 90000100000000 | grep 90000017043403
90000017043403
shlomif[ProjEuler]:~/progs/riddles/project-euler/git/project-euler/3$ primesieve -p1 90000000000000 90000100000000 | grep 90000017043403
shlomif[ProjEuler]:~/progs/riddles/project-euler/git/project-euler/3$ factor 90000017043403
90000017043403: 407899 220642897
shlomif[ProjEuler]:~/progs/riddles/project-euler/git/project-euler/3$ 

I'm going to use primesieve from now on until this problem is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant