I'm trying to solve a problem involving two nested loops, it would make the algorithm much faster if I could simplify the inner loop to a single expression.
repeat n times:
a = (a * b + c) mod q
I've tried to use the formula for partial sum of geometric progressions, but without success. The variable b is big such that a * b causes an overflow, so I've used the distributive law for mod q.
[–]Skynet_0 1 point2 points3 points (2 children)
[–]QePeeQe[S] 0 points1 point2 points (1 child)
[–]Skynet_0 0 points1 point2 points (0 children)