Problems > Geometric or Not > Editorial

Geometric or Not — Solution & Editorial

Back to the Problem

Avoid division entirely: a GP satisfies ai−1² = ai·ai−2 for every middle term — cross-multiply and compare (also handles zeros gracefully).

Complexity: O(N)

Watch out: Dividing by a zero term crashes; the middle-term identity never divides.