# Order (mathematica)

1. Jul 1, 2007

### axeae

does anyone know how to find the order of a number in mathematica? all a google search turns up is ordering numbers :rofl:

thanks

whoops, this should be in number theory

and for those who were wondering, its MultiplicativeOrder[a,n]

Last edited: Jul 1, 2007
2. Jul 1, 2007

### matt grime

I don't understand. Isn't MultiplicativeOrder[a,n] precisely the thing you want? And you aren't finding the order of a number. You're finding the order of a number modulo n. A number does not have an order.

3. Jul 1, 2007

### Kummer

Just be careful how you use that function. If gcd(a,n)!=1 then it will crash.

4. Jul 1, 2007

### matt grime

Why will it crash? Surely it verifies that a and n are coprime first (which is a trivial calculation).

5. Jul 1, 2007

### axeae

yeah sorry for the confusion, I posted this and then realized it was in the wrong section and then finally found the command.

btw if gcd(a,n)!=1, it just returns no output in Mathematica 6

edit: yeah I misspoke, I should have said order of a number mod n, in my example a was the number and n was the mod.