Group Abstract Group Abstract

Message Boards Message Boards

0
|
4K Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Finding the Order of A Number Modulo 17

Posted 11 years ago

I'm trying to write a code to find a number in the field of integers Mod 17 which has order 16. This is my first time using Mathematica and I feel really lost in the syntax (my file is attached).

My approach is to start with the number 2 and just see if 2^2 (mod 17) is equivalent to 1. If not, I increase the power by one and check it again. I keep doing this until 2^p (mod 17) is equivalent to 1, and then I check to see if p == 16. If not, I just start the whole process over again with 3, and I do this until I find a number which is equivalent to 1 for the first time when taken to the power 16. Where am I going wrong with my code?

Edit: I've uploaded a more current file but I'm still not sure what is wrong.

Attachments:
POSTED BY: Kevin Nickerson
3 Replies
POSTED BY: Ilian Gachevski
Posted 11 years ago
POSTED BY: Kevin Nickerson

Where am I going wrong with my code?

You've got lots of basic syntax error. May be you should start with small example first in order to learn the basic syntax., You need ";" to separate statements in M. You can't write

k = 2;
p = 2
While[k < 17,
 p = 1
   While[GF[17][{k}]^p =!= 1,
    p ++
    ]
   If[p == 16, 
    Print [k]
     Break[]
    ];
 k++
 ]

notice there is no ";" after the p=1 and no ";" after the ] there., You also need ";" after the Print.

It is important to know the difference between "," and ";" in Mathematica. I have not tried to run your code, just an observation. Also the GF[17][{k}]^p looks strange but I never used this function. Have you tried to test this on its own first to make sure you get the syntax correct?

POSTED BY: Nasser M. Abbasi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard