ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 09 Jul 2020 15:44:06 +0200I cannot seem to figure out what's wrong with the following Sage / Pari-GP codehttps://ask.sagemath.org/question/52390/i-cannot-seem-to-figure-out-whats-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](https://sagecell.sagemath.org/), 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!Thu, 09 Jul 2020 15:13:09 +0200https://ask.sagemath.org/question/52390/i-cannot-seem-to-figure-out-whats-wrong-with-the-following-sage-pari-gp-code/Answer by FrédéricC for <p>Basically, I would like to search for primes $p$, and positive integers $y, z$ satisfying
$$y < z$$
and
$$1 + p^y < 2p^{2y-z}.$$</p>
<pre><code>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)))))
</code></pre>
<p>When I try to compile the above code using <a href="https://sagecell.sagemath.org/">Sage Cell Server</a>, it gives me the following error:</p>
<pre><code>*** syntax error, unexpected ')': ...int(p," ",y," ",z)))))
</code></pre>
<p><em>*</em> ^-
Help | Powered by SageMath</p>
<p>I did already check and verified that all the parentheses are in their proper places.</p>
<p>Please help!</p>
https://ask.sagemath.org/question/52390/i-cannot-seem-to-figure-out-whats-wrong-with-the-following-sage-pari-gp-code/?answer=52391#post-id-52391Missing* (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)))))Thu, 09 Jul 2020 15:34:11 +0200https://ask.sagemath.org/question/52390/i-cannot-seem-to-figure-out-whats-wrong-with-the-following-sage-pari-gp-code/?answer=52391#post-id-52391Comment by Jose Arnaldo Bebita-Dris for <p>Missing* (twice)</p>
<pre><code>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)))))
</code></pre>
https://ask.sagemath.org/question/52390/i-cannot-seem-to-figure-out-whats-wrong-with-the-following-sage-pari-gp-code/?comment=52393#post-id-52393Thank you for your answer. I was able to figure it out as you were about to post your answer.Thu, 09 Jul 2020 15:44:06 +0200https://ask.sagemath.org/question/52390/i-cannot-seem-to-figure-out-whats-wrong-with-the-following-sage-pari-gp-code/?comment=52393#post-id-52393Answer by Jose Arnaldo Bebita-Dris for <p>Basically, I would like to search for primes $p$, and positive integers $y, z$ satisfying
$$y < z$$
and
$$1 + p^y < 2p^{2y-z}.$$</p>
<pre><code>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)))))
</code></pre>
<p>When I try to compile the above code using <a href="https://sagecell.sagemath.org/">Sage Cell Server</a>, it gives me the following error:</p>
<pre><code>*** syntax error, unexpected ')': ...int(p," ",y," ",z)))))
</code></pre>
<p><em>*</em> ^-
Help | Powered by SageMath</p>
<p>I did already check and verified that all the parentheses are in their proper places.</p>
<p>Please help!</p>
https://ask.sagemath.org/question/52390/i-cannot-seem-to-figure-out-whats-wrong-with-the-following-sage-pari-gp-code/?answer=52392#post-id-52392Blimey! 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.Thu, 09 Jul 2020 15:42:37 +0200https://ask.sagemath.org/question/52390/i-cannot-seem-to-figure-out-whats-wrong-with-the-following-sage-pari-gp-code/?answer=52392#post-id-52392