mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   PARI/GP (https://www.mersenneforum.org/forumdisplay.php?f=155)
-   -   PARI's commands (https://www.mersenneforum.org/showthread.php?t=13636)

CRGreathouse 2010-08-16 13:47

[QUOTE=3.14159;225662]But that only gets rid of one divisor, 229. What if we wished to get rid of 229 and 233?[/QUOTE]

Duh, wrap the whole thing in a forprime(p=229,233, ___). :smile:

That's why you want the calculations to find the starting point rather than just finding it on your own beforehand.

3.14159 2010-08-16 14:11

[QUOTE=CRGreathouse]Duh, wrap the whole thing in a forprime(p=229,233, ___).
[/QUOTE]

forprime(p=a,b,forstep(n=lift(Mod(-1,p)/(x!),10^m,p,...)?

CRGreathouse 2010-08-16 14:13

I have to drag you kicking and screaming, don't I.

So inside the loop you know that exponent n is bad (creates a number divisible by p). So you need to have a list of numbers and mark number n as bad (whatever value you choose for that).

3.14159 2010-08-16 14:25

[QUOTE=CRGreathouse]So inside the loop you know that exponent n is bad (creates a number divisible by p). So you need to have a list of numbers and mark number n as bad (whatever value you choose for that).
[/QUOTE]

A particular k-value is bad if k * n! + 1 makes a value divisible by a small prime.
If a certain k * n! + 1 is divisible by, let's say, 2550871, I would make a forstep loop, where the step size = 2550871, where all the k-values that would be divisible by 2550871 are eliminated.

If n = 430, and k goes up to 10[sup]8[/sup]:

Eliminated k's are:

[code]702669
3253540
5804411
8355282
10906153
13457024
16007895
18558766
21109637
23660508
26211379
28762250
31313121
33863992
36414863
38965734
41516605
44067476
46618347
49169218
51720089
54270960
56821831
59372702
61923573
64474444
67025315
69576186
72127057
74677928
77228799
79779670
82330541
84881412
87432283
89983154
92534025
95084896
97635767[/code]

I would have to code that to exclude those numbers, as I know they form a k * 430! + 1 that is divisible by 2550871.

Or: A smaller prime: 577.
There would be 173310 k-values eliminated by 577.

3.14159 2010-08-16 14:53

I thought of a code snippet:
Note: e = variable, not 2.718281828459045..
kfacsieve(a,x,e,b) = {
forprime(p=a,x,
forstep(n=lift(Mod(-1,p)/(e!),10^b,p,print(n))
);
}


(Please check for any errors I might have made there.)

CRGreathouse 2010-08-16 14:54

OK. Now show what's left, not what's removed. You'll generally want to sieve out all the primes in a large range (at the very least 3 to 1e6).

3.14159 2010-08-16 14:58

[QUOTE=CRGreathouse]OK. Now show what's left, not what's removed. You'll generally want to sieve out all the primes in a large range (at the very least 3 to 1e6).
[/QUOTE]

How can I do that? Forstep is only capable of showing what's removed.

CRGreathouse 2010-08-16 15:09

[QUOTE=3.14159;225676]How can I do that? Forstep is only capable of showing what's removed.[/QUOTE]

Clearly this is false. Just store the information instead of printing it.

3.14159 2010-08-16 15:35

[QUOTE=CRGreathouse]Clearly this is false. Just store the information instead of printing it.
[/QUOTE]

There is no such option.

CRGreathouse 2010-08-16 16:12

Ah, so I must have been lying about having constructed a sieve in Pari earlier, and I must be intentionally misleading you now.

3.14159 2010-08-16 16:25

[QUOTE=CRGreathouse]Ah, so I must have been lying about having constructed a sieve in Pari earlier, and I must be intentionally misleading you now.
[/QUOTE]

Not exactly what I said, but cool strawman, anyway.


All times are UTC. The time now is 23:03.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.