Ask Your Question
1

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

asked 2020-07-09 08:13:09 -0500

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 flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
1

answered 2020-07-09 08:42:37 -0500

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.

edit flag offensive delete link more
1

answered 2020-07-09 08:34:11 -0500

FrédéricC gravatar image

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)))))
edit flag offensive delete link more

Comments

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

Jose Arnaldo Bebita-Dris gravatar imageJose Arnaldo Bebita-Dris ( 2020-07-09 08:44:06 -0500 )edit

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-07-09 08:13:09 -0500

Seen: 39 times

Last updated: Jul 09