Quote:
Originally Posted by carpetpool
Hi,
The following code is to generate prime indices of prime Fibonacci numbers in GP in a certain index range.
Code:
v=[3, 4]; forprime(p=5, 1e5, if(ispseudoprime(fibonacci(p)), v=concat(v, p)));
I find this code very useful for when the fibonacci(p) sequence is replaced by another divisiblity sequence a(p) (defined in GP).
Code:
v=[]; forprime(p=1, 1e5, if(ispseudoprime(a(p)), v=concat(v, p)));
which will list the primes p such that a(p) is prime for (p given in a certain range).
Now the bad thing or catch about this is PARI's pseudoprime(n) function is seemingly slow if n is a (considerably large, say 1000+ digits) pseudoprime (probable prime). Since PARI/GP seems to be fast at generating the terms for a(p), (which PFGW cannot do for all sequences and highorder recurrence relations), can someone come up with a modification to fiabonacci(p) code so that PARI/GP generates the primeindex Fibonacci numbers, and PFGW 3PRP tests them. (I am aware of PFGW's builtin fibonacci function, however I don't want that being used here because if PARI is able to generate the fibonacci terms, it will also be able to for other sequences, which PFGW can easily PRP test.
Thanks for help.
The following GP code is from here.

technically, the new PARI 2.10.0 alpha ( or the newest one I have) has a fibonacci command. maybe test other conditions to weed things out a bit first ? programming efficiently relates to testing conditions that are faster first and only going for the big ones later. maybe try changing the flag to change the test being used behind the scenes ? edit: two edits to your first code made a small speed up ( changed to parforprime and called the fibonacci outside the ispseudoprime test part in parallel).