11.07.2015 Views

Cryptography - Sage

Cryptography - Sage

Cryptography - Sage

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

sage: n = 12sage: for i in range(n):....: if gcd(i,n) == 1:....: print i # now hit enter twice....:15711Putting together our use of sets, we demonstrate the use of if and while loops to constructthe same set of integers in 0,..,n:sage: n = 12sage: r = euler_phi(n)sage: i = 1sage: S = set([i])sage: while len(S) < r:....: i += 1....: if GCD(i,n) == 1:....: S.add(i) # hit enter twice....:sage: Sset([1, 11, 5, 7])In each instance the indentation level is crucial to determine the limits of the loops, whichcan consist of several lines of commands.Python StringsA useful Python types for this course will be strings, which can be created by enclosinginput in double quotes or in single quotes.94 Appendix A. SAGE Constructions

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!