static void generators(BigInteger p) {
        int count = 0;

        for (int g = 2; g <= p.intValue() - 2; g++) {
            int counter = 0, m = 1, i;
            boolean b[] = new boolean[p.intValue()];

            for (i = 0; i < p.intValue(); i++) {
                b[i] = false;
            }

            try {
                for (i = 1; i <= p.intValue() - 1; i++) {
                    m = (m * g) % p.intValue();
                    if (!b[m]) {
                        b[m] = true;
                        counter++;
                        if (counter == p.intValue() - 1) {
                            count++;
                        }
                    } else {
                        break;
                    }
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            // System.out.println("\nNo. of generators are " + count);
        }
    }