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-17 18:18

Your statements are , likewise, unclear to me. (Why are you trying to make em2 a vector?!?) But I know that it can be done since I do this all the time.

3.14159 2010-08-17 18:18

Vectors are inefficient and unnecessary here. em2 and mem were decent advances. em2 and mem were, as I see it, the most progress I ever made.

3.14159 2010-08-17 18:22

[QUOTE=CRGreathouse]Your statements are , likewise, unclear to me. (Why are you trying to make em2 a vector?!?) But I know that it can be done since I do this all the time.
[/QUOTE]

Nevermind that. I'm going to go in the direction I was going in using em2 and mem.

mem needs some fixing in order to avoid the loop repeat: em2 is 100% functional.

CRGreathouse 2010-08-17 18:30

Well, post your functions and maybe we can compare.

kar_bon 2010-08-17 18:34

Not so hard to understand:

You searching for say k*360! + 1,

so set
v[1]=1 (k=1)
v[2]=2 (k=2)
v[3]=3 (k=3)
...
v[n]=n (k=n)

for all k-values you want to search for.

If you find a primefactor of say 123*360!+1, set v[123]=0.

Do this for all primefactors you will test: set the vector[index]=0.

After you've sieved all primefactors, the vector v contains some/many values set to 0, so these indices have a small factor and you do not need to test them.

You can "print" all indices n, where v[n] != 0, -> no primefactor found after sieving -> list of all k-values to test!

CRGreathouse 2010-08-17 18:43

Yes. Though I would set them all to 1 rather than to their own values -- you know that from their location. Of course ideally you'd use just one bit per number rather than a whole word, but for convenience in Pari I usually don't bother.

kar_bon 2010-08-17 18:49

[QUOTE=CRGreathouse;225900]Yes. Though I would set them all to 1 rather than to their own values -- you know that from their location. Of course ideally you'd use just one bit per number rather than a whole word, but for convenience in Pari I usually don't bother.[/QUOTE]

Yes, that's only necessary but to show the relation of factor and index...

And further:

There's no need to divide every candidate by that small factor:

Find the first occurence and the step-width (like in the example from yesterday) and it's a simple for-loop to strike out all candidates with that small factor!

3.14159 2010-08-17 18:50

[QUOTE=Karsten]v[1]=1 (k=1)
v[2]=2 (k=2)
v[3]=3 (k=3)
...
v[n]=n (k=n)[/QUOTE]

v[n] returns : "not a vector", for any n used.

[QUOTE=Charles]Well, post your functions and maybe we can compare.
[/QUOTE]

Look at the code snippets I posted earlier on.

3.14159 2010-08-17 18:54

[QUOTE=Karsten]Find the first occurence and the step-width (like in the example from yesterday) and it's a simple for-loop to strike out all candidates with that small factor!
[/QUOTE]

Fair enough.

Interesting coincidence: 353, 360, and 367 are all 7 units apart.

353 * 360! + 1 is divisible by 367.

CRGreathouse 2010-08-17 19:06

[QUOTE=3.14159;225903]v[n] returns : "not a vector", for any n used.[/QUOTE]

Yeah, I told you half a dozen times how to handle that, including a commentary of the effectiveness of different versions.

[code]v=vector(number_of_k_values_to_test)[/code]

[QUOTE=3.14159;225903]Look at the code snippets I posted earlier on.[/QUOTE]

I have twice asked for the omitted portion, without which I cannot duplicate or even follow your code.

3.14159 2010-08-17 19:09

[QUOTE=CRGreathouse]I have twice asked for the omitted portion, without which I cannot duplicate or even follow your code.
[/QUOTE]

What omitted portion? em2 and mem have nothing missing!

If you're referring to em2:

em2(x,n,a)=forstep(b=lift(Mod(-1,x)/n),10^a,x, print(b))

[QUOTE=CRGreathouse]Yeah, I only told you half a dozen times how to handle that, including a commentary of the effectiveness of different versions.
[/QUOTE]

6? O rly?


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

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