public static int unitGroupElementOrder(final int element, final int n) {
        positiveCheck(element);
        notLessThanCheck(n, 2);
        if (element == 1)
            return 1;
        
        final List<Integer> unitGroup = elementsOfUnitGroup(n);
        if (!unitGroup.contains(element))
            throw new IllegalArgumentException(element + " is not an element of Z" + n + "×");
        
        final List<Integer> possibleElementOrders = divisors(unitGroup.size());
        for (int i = 0; i < possibleElementOrders.size(); ++i) {
            final int currentOrder = possibleElementOrders.get(i);
            if (modPow(element, currentOrder, n) == 1)
                return currentOrder;
        }
        return Integer.MAX_VALUE;
    }