private static boolean binomialCongruenceLemma(final int n, int a,
            final int m, final StringBuilder result) {
             
        if ((Algorithms.isCoprime(a, m)) && (Algorithms.primitiveRootsExist(m))) {
            final int phiM = Algorithms.eulerPhi(m);
            final int d = Algorithms.gcd(n, phiM);
            final int test = Algorithms.modPow(a, phiM / d, m);
            
            final StringBuilder lineEnd = buildModLineEnd(m);
            if (normalizeIntModuloChanges(a, m)) {
                a = Algorithms.normalizeIntModulo(a, m);
                result.append(buildBinomialCongruence(1, 'x', n, 0, -a, lineEnd));
            }
            result.append(buildGCDEquals(a, m)).append(1).append(NEWLINE);
            result.append(buildPhiEquals(m)).append(phiM).append(NEWLINE);
            result.append(buildGCDEquals(n, phiM)).append(d).append(NEWLINE);
            result.append(buildModPowResult(test, buildModPowLineStart(a, phiM / d),
                    lineEnd)).append(SEPARATOR);
            if (test != 1)
                return false;
        }
        return true;
    }