# is there any possibility to write and calculate this sum in pari gp, which is very related to hardy littlewood first conjecture?

I studied hardy littlewood first conjecture, which predicts the density of primes of special form, so:

if I want to know the number of the primes of the form $$2kp+1$$, where $$p$$ is prime and $$p \leq x$$, then, according to hardy littlewood first conjecture, it is about $$2c_2\frac{x}{\ln^2 x}\prod^{}_{2 where $$c_2$$ is hardy littlewood twin primes constant,

Now, if I want to know the number of the primes of the form $$2kp+1$$ where $$1 \leq k \leq n$$, $$p$$ is prime, and $$p \leq x$$, then it will be about

$$2c_2\frac{x}{\ln^2 x} \sum^{n}_{k=1} \prod^{}_{2

Now my question is, is there any possibility to write and calculate this sum in pari gp calculator $$\sum^{n}_{k=1} \prod^{}_{2

• sum(k=1,n,prod(q=3,2*k,if((2*k)%q==0,(q-1)/(q-2),1))). n=7;sum(..)=547/40, n=17;sum(..)=18037309/480480, this true calculations? Commented May 16, 2020 at 6:07
• thank you very much sir for this comment, it is a wonderful answer, but according to the fact that $q$ is prime, then the code must be sum(k=1,n,prod(q=2,2*k,if((2*k)%prime(q)==0,(prime(q)-1)/(prime(q)-2),1))), I tried the code, and it is correct, but could you please put your comment as an answer, so I can accept it, and of course upvote it, because it is actually a wonderful answer
– user788522
Commented May 16, 2020 at 8:07
• But prime(q) return q-th prime. Then is true n=7;sum(k=1,n,prod(q=3,2*k,if(isprime(q)&(2*k)%q==0,(q-1)/(q-2),1)))=143/15, n=17;sum(..)=11881/495? Commented May 16, 2020 at 8:31
• yes, this code is correct, I suggest you to put it as an answer
– user788522
Commented May 16, 2020 at 8:42
• You are aware that the asymptotic is conjectured to hold only as $x\to \infty$, not as $k\to \infty$, which means that you need to hold $n$ fixed and let $x\to \infty$, you can't let $n\to \infty$ without a deeper discussion. Commented May 16, 2020 at 15:27

sum(k=1,n,prod(q=3,2*k,if(isprime(q)&(2*k)%q==0,(q-1)/(q-2),1)))

Examples:

n=7;sum(..)=143/15

n=17;sum(..)=11881/495

• hi sir, I have a question about the stored codes in pari, is it possible to delete or remove them, because I have thousands of them, and it takes me a few hours to search for a previous important code ?
– user788522
Commented May 18, 2020 at 23:09
• @hosamRamsey. Not understand your question. Edit and save your gp-code in any txt-editor (i use Far-editor), and run your code in pari/gp as \r file.gp. Commented May 19, 2020 at 3:12
• I am very sorry, but I mean that is there any possibility to delete or remove all the stored codes in pari gp ?, in other words, I want to do a reset factor to pari gp
– user788522
Commented May 19, 2020 at 7:56
• @hosamRamsey. Sorry, me english from google translate, for me your question is not understand. Commented May 19, 2020 at 10:47
• ok sir, thank you, and sorry for annoying
– user788522
Commented May 19, 2020 at 15:57