在下面的片段中,请从第一个“for”循环开始解释发生了什么以及为什么。为什么加0,为什么在第二个循环中加1。bigi 下的“if”语句中发生了什么。最后解释一下modPow方法。提前感谢您的有意义的答复。
public static boolean isPrimitive(BigInteger m, BigInteger n) {
    BigInteger bigi, vectorint;
    Vector<BigInteger> v = new Vector<BigInteger>(m.intValue());
    int i;
    for (i=0;i<m.intValue();i++)
        v.add(new BigInteger("0"));
    for (i=1;i<m.intValue();i++)
    {
        bigi = new BigInteger("" + i);
        if (m.gcd(bigi).intValue() == 1)
            v.setElementAt(new BigInteger("1"), n.modPow(bigi,m).intValue());
    }
    for (i=0;i<m.intValue();i++)
    {
        bigi = new BigInteger("" + i);
        if (m.gcd(bigi).intValue() == 1)
        {
            vectorint = v.elementAt(bigi.intValue());
            if ( vectorint.intValue() == 0)
                i = m.intValue() + 1;
        }
    }
    if (i == m.intValue() + 2)
        return false;
    else
        return true;
}