Cycle detection
Detecting cycles in iterated function sequences is a sub-problem in many computer algorithms, such as factoring prime numbers. Some such algorithms are highly space efficient, such as Floyd's cycle-finding algorithm, also called the "tortoise and the hare algorithm". A more efficient algorithm is Brent's Cycle algorithm.
See https://en.wikipedia.org/wiki/Cycle_detection for a discussion of the theory.