Back to the Problem
Closed form A(RN−1)/(R−1) with a modular inverse, special-casing R ≡ 1.
Complexity: O(log N)