Ask Your Question

# I cannot seem to figure out what's wrong with the following Sage / Pari-GP code

Basically, I would like to search for primes $p$, and positive integers $y, z$ satisfying $$y < z$$ and $$1 + p^y < 2p^{2y-z}.$$

for(p=1, 10000, for(y=1, 10000, for(z=1, 10000, if(isprime(p) && y<z && 1+p^y<2p^(2y-z),print(p,"   ",y,"   ",z)))))


When I try to compile the above code using Sage Cell Server, it gives me the following error:

***   syntax error, unexpected ')': ...int(p," ",y," ",z)))))


* ^- Help | Powered by SageMath

I did already check and verified that all the parentheses are in their proper places.

Please help!

edit retag close merge delete

## 2 Answers

Sort by » oldest newest most voted

Missing* (twice)

for(p=1, 10000, for(y=1, 10000, for(z=1, 10000, if(isprime(p) && y<z && 1+p^y<2*p^(2*y-z),print(p,"   ",y,"   ",z)))))

more

## Comments

Thank you for your answer. I was able to figure it out as you were about to post your answer.

( 2020-07-09 15:44:06 +0200 )edit

Blimey! I was able to figure it out.

for(p=1, 10000, for(y=1, 10000, for(z=1, 10000, if(y < z && 1 + p^y < 2*p^(2*y-z) && isprime(p),print(p,"   ",y,"   ",z)))))


It is a common mistake of mine. I keep forgetting the * to indicate multiplication.

more

## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2020-07-09 15:13:09 +0200

Seen: 42 times

Last updated: Jul 09 '20