Ask Your Question
1

Cryptographic Mathematics

asked 2016-10-01 14:00:06 -0600

anonymous user

Anonymous

updated 2016-10-01 14:24:47 -0600

tmonteil gravatar image

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?

edit retag flag offensive close merge delete

Comments

i=7 n=2 for n in range(2,100): i=i+gcd(n,i) print i

sootalhzn gravatar imagesootalhzn ( 2016-10-01 16:04:16 -0600 )edit

2 answers

Sort by » oldest newest most voted
1

answered 2016-10-01 14:29:21 -0600

tmonteil gravatar image

updated 2016-10-01 14:45:32 -0600

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

Comments

could you please post the code of Sage?

sootalhzn gravatar imagesootalhzn ( 2016-10-01 14:36:54 -0600 )edit

Your 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.

tmonteil gravatar imagetmonteil ( 2016-10-01 14:42:44 -0600 )edit

i=7 n=2 for n in range(2,100): i=i+gcd(n,i) print i

sootalhzn gravatar imagesootalhzn ( 2016-10-01 16:02:34 -0600 )edit
1

answered 2016-10-01 16:05:17 -0600

sootalhzn gravatar image

Update:

i=7
n=2
for n in range(2,100):
    i=i+gcd(n,i)
    print i
edit flag offensive delete link more

Comments

  • 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).
tmonteil gravatar imagetmonteil ( 2016-10-01 17:05:06 -0600 )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: 2016-10-01 13:57:52 -0600

Seen: 111 times

Last updated: Oct 01 '16