The document says O(log(m+a)), but now (by #92) m+a may be negative or zero. I suggest O(log(a mod m)).
By the way, maybe, its complexity could be bounded by O(log(min(n, a mod m))). It might be wrong because I guessed just intuitively (and empirically). So I'm glad if anyone can analyze this.
The document says
O(log(m+a)), but now (by #92)m+amay be negative or zero. I suggestO(log(a mod m)).By the way, maybe, its complexity could be bounded by
O(log(min(n, a mod m))). It might be wrong because I guessed just intuitively (and empirically). So I'm glad if anyone can analyze this.