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.Sun, 02 Oct 2016 00:05:06 +0200Cryptographic Mathematicshttps://ask.sagemath.org/question/35013/cryptographic-mathematics/**Q: Programme Rowland’s formula and verify his results. Try different starting values and see what happens.**
In Sage math cloud, I did this:
i =7
n=2
for n in [1..10]:
i=i+gcd(n,i)
print i
***********
Could you help, please?Sat, 01 Oct 2016 20:57:52 +0200https://ask.sagemath.org/question/35013/cryptographic-mathematics/Comment by sootalhzn for <p><strong>Q: Programme Rowland’s formula and verify his results. Try different starting values and see what happens.</strong></p>
<p>In Sage math cloud, I did this:</p>
<pre><code>i =7
n=2
for n in [1..10]:
i=i+gcd(n,i)
print i
</code></pre>
<hr>
<p>Could you help, please?</p>
https://ask.sagemath.org/question/35013/cryptographic-mathematics/?comment=35025#post-id-35025i=7
n=2
for n in range(2,100):
i=i+gcd(n,i)
print iSat, 01 Oct 2016 23:04:16 +0200https://ask.sagemath.org/question/35013/cryptographic-mathematics/?comment=35025#post-id-35025Answer by tmonteil for <p><strong>Q: Programme Rowland’s formula and verify his results. Try different starting values and see what happens.</strong></p>
<p>In Sage math cloud, I did this:</p>
<pre><code>i =7
n=2
for n in [1..10]:
i=i+gcd(n,i)
print i
</code></pre>
<hr>
<p>Could you help, please?</p>
https://ask.sagemath.org/question/35013/cryptographic-mathematics/?answer=35015#post-id-35015Here are some hints:
- please re-read Rowland's formula, the interesting sequence is not $a(n)$ but the first difference $a(n)-a(n-1)$,
- If you want to see some primes appearing (not only 1's), you should look for more than only the first 10 values,
- the line `n=2` is useless since it is erased by the next loop, if you want to start at `n=2` your loop should look like : `for n in range(2,100):`,
- what is inside your loop should be indented
- to verify the formula, you should make a test that discards the 1's appearing, and that check and prints the other if they are prime (and raise/print an error message if not).Sat, 01 Oct 2016 21:29:21 +0200https://ask.sagemath.org/question/35013/cryptographic-mathematics/?answer=35015#post-id-35015Comment by sootalhzn for <p>Here are some hints:</p>
<ul>
<li>please re-read Rowland's formula, the interesting sequence is not $a(n)$ but the first difference $a(n)-a(n-1)$,</li>
<li>If you want to see some primes appearing (not only 1's), you should look for more than only the first 10 values,</li>
<li>the line <code>n=2</code> is useless since it is erased by the next loop, if you want to start at <code>n=2</code> your loop should look like : <code>for n in range(2,100):</code>,</li>
<li>what is inside your loop should be indented</li>
<li>to verify the formula, you should make a test that discards the 1's appearing, and that check and prints the other if they are prime (and raise/print an error message if not).</li>
</ul>
https://ask.sagemath.org/question/35013/cryptographic-mathematics/?comment=35016#post-id-35016**could you please post the code of Sage?**Sat, 01 Oct 2016 21:36:54 +0200https://ask.sagemath.org/question/35013/cryptographic-mathematics/?comment=35016#post-id-35016Comment by tmonteil for <p>Here are some hints:</p>
<ul>
<li>please re-read Rowland's formula, the interesting sequence is not $a(n)$ but the first difference $a(n)-a(n-1)$,</li>
<li>If you want to see some primes appearing (not only 1's), you should look for more than only the first 10 values,</li>
<li>the line <code>n=2</code> is useless since it is erased by the next loop, if you want to start at <code>n=2</code> your loop should look like : <code>for n in range(2,100):</code>,</li>
<li>what is inside your loop should be indented</li>
<li>to verify the formula, you should make a test that discards the 1's appearing, and that check and prints the other if they are prime (and raise/print an error message if not).</li>
</ul>
https://ask.sagemath.org/question/35013/cryptographic-mathematics/?comment=35017#post-id-35017Your code is a good start, so you should get a correct code from my remarks (i updated it to be more precise). Please do not hesitate to provide some new attempts and ask for comments.Sat, 01 Oct 2016 21:42:44 +0200https://ask.sagemath.org/question/35013/cryptographic-mathematics/?comment=35017#post-id-35017Comment by sootalhzn for <p>Here are some hints:</p>
<ul>
<li>please re-read Rowland's formula, the interesting sequence is not $a(n)$ but the first difference $a(n)-a(n-1)$,</li>
<li>If you want to see some primes appearing (not only 1's), you should look for more than only the first 10 values,</li>
<li>the line <code>n=2</code> is useless since it is erased by the next loop, if you want to start at <code>n=2</code> your loop should look like : <code>for n in range(2,100):</code>,</li>
<li>what is inside your loop should be indented</li>
<li>to verify the formula, you should make a test that discards the 1's appearing, and that check and prints the other if they are prime (and raise/print an error message if not).</li>
</ul>
https://ask.sagemath.org/question/35013/cryptographic-mathematics/?comment=35024#post-id-35024i=7
n=2
for n in range(2,100):
i=i+gcd(n,i)
print iSat, 01 Oct 2016 23:02:34 +0200https://ask.sagemath.org/question/35013/cryptographic-mathematics/?comment=35024#post-id-35024Answer by sootalhzn for <p><strong>Q: Programme Rowland’s formula and verify his results. Try different starting values and see what happens.</strong></p>
<p>In Sage math cloud, I did this:</p>
<pre><code>i =7
n=2
for n in [1..10]:
i=i+gcd(n,i)
print i
</code></pre>
<hr>
<p>Could you help, please?</p>
https://ask.sagemath.org/question/35013/cryptographic-mathematics/?answer=35026#post-id-35026Update:
i=7
n=2
for n in range(2,100):
i=i+gcd(n,i)
print iSat, 01 Oct 2016 23:05:17 +0200https://ask.sagemath.org/question/35013/cryptographic-mathematics/?answer=35026#post-id-35026Comment by tmonteil for <p>Update:</p>
<pre><code>i=7
n=2
for n in range(2,100):
i=i+gcd(n,i)
print i
</code></pre>
https://ask.sagemath.org/question/35013/cryptographic-mathematics/?comment=35027#post-id-35027- as i told before, the second line is useless
- the Rowland sequence is not the list of `i` but `i-iold`.
- you will get a lot of 1, so instead of printing them, you should only print the `i-iold` that are different from 1, use an *if statement*.
- actually, your loop should go to 1000 or even 10000 (which makes sense only if you ignore the 1, or you won't see anything).Sun, 02 Oct 2016 00:05:06 +0200https://ask.sagemath.org/question/35013/cryptographic-mathematics/?comment=35027#post-id-35027