Power algorithm on monoids/semigroups, plus linear recurrence sequence computation.