First time here? Check out the FAQ!

Ask Your Question
1

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

asked 4 years ago

Basically, I would like to search for primes p, and positive integers y,z satisfying y<z

and 1+py<2p2yz.

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!

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 4 years ago

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)))))
Preview: (hide)
link

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 ( 4 years ago )
1

answered 4 years ago

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.

Preview: (hide)
link

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: 4 years ago

Seen: 289 times

Last updated: Jul 09 '20