mersenneforum.org  

Go Back   mersenneforum.org > Math Stuff > Computer Science & Computational Number Theory > PARI/GP

Reply
 
Thread Tools
Old 2010-08-24, 00:15   #804
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

203008 Posts
Default

got it working.

Code:
sievex(kmin,kmax,b,n,pmax)=a=0;for(k=kmin,kmax,forprime(p=1,pmax,if((k*b!^n+1)%p==0 && (k*b!^n+1)!=p,a=a+1));if(a==0,print("no factor found for"k"*"b"!^"n"+1 in this range"));a=0)
science_man_88 is offline   Reply With Quote
Old 2010-08-24, 00:18   #805
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24·3·5·7 Posts
Default

Quote:
Originally Posted by Karsten
The '!' was not the factorial-sign!
An integer followed by an exclamation point is taken as a factorial to me.
3.14159 is offline   Reply With Quote
Old 2010-08-24, 01:01   #806
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

20C016 Posts
Default

!

factorial
factorial
combinatorics
n! means the product 1 × 2 × ... × n. 4! = 1 × 2 × 3 × 4 = 24
logical negation
not
propositional logic
The statement !A is true if and only if A is false.

A slash placed through another operator is the same as "!" placed in front.

(The symbol ! is primarily from computer science. It is avoided in mathematical texts, where the notation ¬A is preferred.) !(!A) ⇔ A
x ≠ y ⇔ !(x = y)

according to wikipedia's table.
science_man_88 is offline   Reply With Quote
Old 2010-08-24, 01:36   #807
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

168010 Posts
Default

Yes, yes, I know the connotations of the "!", symbol.

I can cite a few quick examples:

7! = 5040
6 * 6 != 7.

Last fiddled with by 3.14159 on 2010-08-24 at 01:38
3.14159 is offline   Reply With Quote
Old 2010-08-24, 03:00   #808
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
It is a sieve that kicks out bad k-values for numbers of the form k * b!n + 1 which are divisible by small primes, where the user is allowed to choose the k-range, the factorial base and the exponent, as well as the largest prime it will sieve up to. The output will be written to a file for testing. The user will have to make the modifications to ensure that the range will be testable, preferably with a decent or advanced text editor that is capable of doing so.

Where k < b!n, and where k, b, and n are positive integers.


I've given up trying to explain this. Here's my off-the-top-of-my-head code, with some basic comments:
Code:
vk(lim,kmin,kmax,b,n,c=-1)={
  my(v=vectorsmall(kmax,j,j>=kmin),start,vv,i=0);
  forprime(p=2,lim,
    trap(,next, \\ if p can't divide any of the members, just go on the next prime
      start=lift(Mod(c,p)/Mod(b,p)^n); \\ start * b^n = c (mod p)
    );
    start += p*ceil((kmin-start)/p); \\ start >= kmin
    forstep(j=start,kmax,p,
      v[j]=0 \\ j * b^n = c (mod p)
    )
  );
  vv=vector(sum(i=1,#v,v[i])); \\ vector for the numbers found, rather than 0/1
  for(j=1,#v,if(v[j],vv[i++]=j)); \\ fill vector
  vv \\ output
};
addhelp(vk, "vk(lim,kmin,kmax,b,n,{c=-1}): Returns those k with kmin <= k <= kmax for which k * b^n - c has no prime divisors up to lim.");
Test code for k * 19!^6 + 1, k <= 10^4:
Code:
vk(1e6,1,10^4,19!,6,-1)
This takes 200 ms. Comparable trial division takes 1 minute 29 seconds:
Code:
B=19!^6;for(k=1,1e4,forprime(p=2,1e6,if((k*B+1)%p==0,break)))
CRGreathouse is offline   Reply With Quote
Old 2010-08-24, 10:01   #809
kar_bon
 
kar_bon's Avatar
 
Mar 2006
Germany

22×727 Posts
Default

Impressive job CRG: 200ms for k<10000!

So I've made my first script for WinPFGW, but it uses only trial factoring for small primes and PRP-test the k-values where no factor was found for.

It creates a log-file like this (found primes/PRP are stored in "pfgw.log", too):
Code:
146*19!^6+1: factor 47
147*19!^6+1: factor 31
148*19!^6+1: factor 41
149*19!^6+1: factor 23
150*19!^6+1: is PRP/PRIME.
151*19!^6+1: no factor found.
152*19!^6+1: factor 6269
153*19!^6+1: no factor found.
154*19!^6+1: factor 883
155*19!^6+1: factor 523
156*19!^6+1: factor 65581
157*19!^6+1: factor 113
158*19!^6+1: factor 12583
159*19!^6+1: factor 31707989
You can choose min-k, max-k, factorial-n, exponent, +/-1 and factor-bound.
There is no code to prevent using false parameters, but that should not be a problem.

Timing: 1 <= k <= 10000, factor-bound = 100000
The script run 24s (here a AMD XP +2500, 1.8GHz) and found 247 PRP/primes.
Attached Files
File Type: txt Sieve_Fakul.txt (2.1 KB, 60 views)
kar_bon is offline   Reply With Quote
Old 2010-08-24, 11:28   #810
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

20C016 Posts
Default

wow even with minimal primelimit and trying a near maximal amount before length overflow with my max memory it's working up to 10^7 in under 17 seconds.
science_man_88 is offline   Reply With Quote
Old 2010-08-24, 11:40   #811
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

69016 Posts
Default

Quote:
Originally Posted by CRGreathouse
I've given up trying to explain this. Here's my off-the-top-of-my-head code, with some basic comments:
No need to be rude. I repeatedly said that I was unable to do it on my own.

Last fiddled with by 3.14159 on 2010-08-24 at 11:48
3.14159 is offline   Reply With Quote
Old 2010-08-24, 11:49   #812
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

168010 Posts
Default

Quote:
Originally Posted by science_man_88
wow even with minimal primelimit and trying a near maximal amount before length overflow with my max memory it's working up to 10^7 in under 17 seconds.
It's a nice script, but I still failed in the end. It's a double-edged sword. I can only write basic scripts.

Only 1.5 minutes for 500 million. Nice.

Last fiddled with by 3.14159 on 2010-08-24 at 11:53
3.14159 is offline   Reply With Quote
Old 2010-08-24, 11:58   #813
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

110100100002 Posts
Default

Quote:
Originally Posted by Karsten
You can choose min-k, max-k, factorial-n, exponent, +/-1 and factor-bound.
There is no code to prevent using false parameters, but that should not be a problem.

Timing: 1 <= k <= 10000, factor-bound = 100000
The script run 24s (here a AMD XP +2500, 1.8GHz) and found 247 PRP/primes.
Can you give us the timings for sieving to a certain prime? (Ex: Time it takes to sieve to 106 for a certain range)

Also: Is it directly input to WinPFGW?

Last fiddled with by 3.14159 on 2010-08-24 at 12:02
3.14159 is offline   Reply With Quote
Old 2010-08-24, 12:08   #814
kar_bon
 
kar_bon's Avatar
 
Mar 2006
Germany

55348 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
Can you give us the timings for sieving to a certain prime? (Ex: Time it takes to sieve to 106 for a certain range)

Also: Is it directly input to WinPFGW?
Start WinPFGW.exe and input in the line under "Standard "PFGW compatible" command line" the name of the script-file (in same folder).

That's all.

You can edit the parameters you need in the script.

(Need for sieve to 10^6 and 1<k<10000 about 50 seconds; window minimized!)
kar_bon is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why do I sometimes see all the <> formatting commands when I quote or edit? cheesehead Forum Feedback 3 2013-05-25 12:56
Passing commands to PARI on Windows James Heinrich Software 2 2012-05-13 19:19
Ubiquity commands Mini-Geek Aliquot Sequences 1 2009-09-22 19:33
64-bit Pari? CRGreathouse Software 2 2009-03-13 04:22
Are these commands correct? jasong Linux 2 2007-10-18 23:40

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


Fri Aug 6 23:09:20 UTC 2021 up 14 days, 17:38, 1 user, load averages: 3.98, 3.92, 3.92

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

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.