Ask Your Question
1

Modular Arithmetic Question using Sage

asked 2010-11-09 15:58:58 +0100

Mathstudent2010 gravatar image

updated 2010-11-09 16:01:15 +0100

Hey forumgoers, just have a question using Sage. I am having trouble with a few questions asked to me, heres the questions, how do can you compute (n-1)! mod n for n < 100. Find a formula relating the number of idempotents in Zsubn with the number of distinct prime factors that n has.

An element a in Z(subn) is a square if there is some b element of Z(subn) such that a^2=b. Find the number of squares in Z(sub p^n).

edit retag flag offensive close merge delete

Comments

Please post what you have tried and maybe a specific question about what you have tried. Some helpful resources are in the tutorial, for example, http://sagemath.org/doc/tutorial/tour_assignment.html This sounds like it might be a homework problem. We'd be doing you a huge disservice if it is and we just handed you the answer.

Jason Grout gravatar imageJason Grout ( 2010-11-10 00:01:47 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2010-11-10 11:00:11 +0100

kcrisman gravatar image

I agree with Jason on most of these. The only one of these which is worthy is the (n-1)! one. I feel like it's ok for me to give Sage commands to do this, though not in one fell swoop - s/he'll still have to put it together.

Keep in mind, though, Mathstudent2010, that your instructor is almost certainly NOT looking for this! Instead a more theoretical result is probably in mind. In particular, although your instructor might find it okay to find a pattern using a computer program, they almost certainly will not appreciate a 'proof' of it using the program. You'll have to discover that part for yourself.

In general, if you want to just see the output of something for a certain number of integers, I recommend

for n in [1..100]:
    print do_this_thing(n)

This isn't the best longterm, but it provides immediate feedback. This is called a loop.

Secondly, the factorial function is easy - for instance, 10! is factorial(10).

Finally, you can get modular arithmetic as well. For instance, 25 modulo 7 is mod(25,7). Put it all together and you should be able to get an answer, possibly showing you a pattern - but not a proof.

edit flag offensive delete link more

Comments

Jason and Kcrisman, thank you for your reply, help and suggestions. Here is what I have been doing: sage: for n in [1..100]: ....: print mod(factorial(n-1), n) ....: 0 1 2 2 4 0 6 0 0 0 10 0 12 0 0 0 16 0 18 0 0 0 22 0 0 0 0 0 28 0 30 0 0 0 0 0 36 0 0 0 40 0 42 0 0 0 46 0 0 0 0 0 52 0 0 0 0 0 58 0 60 0 0 0 0 0 66 0 0 0 70 0 72 0 0 0 0 0 78 0 0 0 82 0 0 0 0 0 88 0 0 0 0 0 0 0 96 0 0 0

Mathstudent2010 gravatar imageMathstudent2010 ( 2010-11-16 13:26:38 +0100 )edit

I think I am going down the right path. Any input would be nice.

Mathstudent2010 gravatar imageMathstudent2010 ( 2010-11-16 13:33:11 +0100 )edit

Yup, you figured out how to get Sage to do this for you - congratulations! The rest is mathematics - observing patterns, verifying them, proving them. Good luck!

kcrisman gravatar imagekcrisman ( 2010-11-17 12:40:55 +0100 )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

Stats

Asked: 2010-11-09 15:58:58 +0100

Seen: 1,550 times

Last updated: Nov 10 '10