how can we use mathematica for POLLARD RHO ALGORITHM to compute the discrete logarithm problem in Zp^*
algorithem is

Let G be a cyclic group of order p, and given , and a partition , let be a map

and define maps and by


Inputs a a generator of G, b an element of G Output An integer x such that ax = b, or failure
  1. Initialise a0 ← 0 b0 ← 0 x0 ← 1 ∈ G i ← 1
  2. xif(xi-1), aig(xi-1,ai-1), bih(xi-1,bi-1)
  3. x2if(f(x2i-2)), a2ig(f(x2i-2),g(x2i-2,a2i-2)), b2ih(f(x2i-2),h(x2i-2,b2i-2))
  4. If xi = x2i then
    1. rbi - b2i
    2. If r = 0 return failure
    3. x ← r -1 (a2i - ai) mod p
    4. return x
  5. If xix2i then ii+1, and go to step 2
any help would be appreciated.


the problem i don't know how to use if anf else in mathematica for many conditions.