On Mon, Apr 5, 2010 at 12:39 PM, D.C. Ernst <[email protected]> wrote: > Great, thanks! This is the sort of thing I was trying, but I wasn't > handling the indentation correctly. Perhaps y'all can help me with a > related issue. I'd like my abstract algebra students to use Sage to > do some computations involving the group of units mod n. I've been > fiddling around myself first. Suppose I do the following in Sage: > > U=Integers(40) > for j in range(1,16): > for k in range(1,40): > if gcd(k,40) == 1: > print (U(k))^j > > As expected, I get a really long list of values. Is there a way to > chop this up in a way that would be palatable to my students? I want > them to do some exploring of orders of elements and I know there are > commands that will just give them the answers I seek, but I want them > to be able to interpret the data. Any suggestions?
Making > print (U(k))^j into print (U(k)^j), # note the comma. might help. > > On Apr 5, 3:17 pm, Mike Hansen <[email protected]> wrote: >> On Mon, Apr 5, 2010 at 12:14 PM, Dana Ernst <[email protected]> wrote: >> > I think I understand how to deal with "for" statements in Sage. For >> > example: >> >> > for j in range(5): >> > print 3^j >> >> > will output the values of 3^0, 3^1, ..., 3^5. However, how could I do this >> > for all the numbers, say 1 to 100, instead of just 3? Maybe this is a >> > silly >> > example, but I'm wondering how to deal with a double-index. >> >> You can do it like this: >> >> for i in range(5): >> for j in range(5): >> print i^j >> >> --Mike > > -- > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/sage-support > URL: http://www.sagemath.org > > To unsubscribe, reply using "remove me" as the subject. > -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
