title: Group theory within Cryptography regarding order of elements in a group of integers Z*p
body: <p>I was kinda thrown in the deep end into group theory and i am a bit lost for a Cryptography class i have.
  Basically a practical i have to implement in java is,</p>
  
  <blockquote>
    <p>order(prime number, list of factors of
    p-1 , any a)</p>
  </blockquote>
  
  <p>This should return the order of a in the group Z*p, where f is a list of prime factors of p-1. Ensure that your method works when f contains duplicates. For example, consider cases where p=17</p>
  
  <p>Here is what i have so far , (taken from steps within my notes)</p>
  
  <pre><code>public static BigInteger order(BigInteger p, List&lt;BigInteger&gt; f, BigInteger a){
      //Algorithm starts like this
      //Start by setting t equal to p-1 i.e t= p1 p2...pn
      BigInteger t = p.subtract(BigInteger.ONE);
      for(BigInteger pi : f){
          //test if a^t1 = 1 mod p where t1 = t/pi
          BigInteger t1 = t.divide(pi);
  
          if(Practical5ExponentiationModMSquareAndMultiply.expm(p, a, t1).equals(BigInteger.ONE)){
              t = t1;
              System.out.println("t after mod = "+t);
              System.out.println("pi after mod = "+pi);
          }
      }       
      return t;
  
  }
  </code></pre>
  
  <p>the list of prime factors f is generated by another method and then passed in</p>
  
  <p>The notes i have are quite difficult to understand and i was wondering if any could tell me what i should actually be returning.
  Also could u give me a possible understanding of this snippet of group theory as it could help with my further practicals</p>