Basically we know that sum of the first $n$ terms in GP is
$$ s = \frac{a(r^n-1)}{r-1} $$
In my problem $a=1$ and it is calculated with modulo $p$
My equation is
$$ s\mathbin\%p = \left(\frac{r^n-1}{r-1}\right)\mathbin\%p $$
I have the values for $s\mathbin\%p$ (but not $s$), $p$, $r$ and also given that $r$ and $p$ are prime numbers. Now I need to find the value of $n$, using this information.
This question is from a live contest (Hackerearth June Circuit). You could asked it after the contest. edit : sorry but i don't have enough reputation to comment.