Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

primes of the form (p^q-q^p)/2 bad syntax?

I am trying to make a really simple code to get a list of primes n of the form (p^q-q^p)/2 where p and q are also prime but something weird is happening. I am using the code:

....: for p in srange(1,100):

....: for q in srange(1,100):

....: if p.is_prime() and q.is_prime() and ((p^q-q^p)/2).is_prime():

....: print(p,q)

But Sage returns no results. But if we let p=3 and q=5, then (3^5-5^3)/2=59 which is prime. What am I doing wrong?!?!? (besides the terrible brute force code lol)