Anonymous user
Modular exponentiation: Difference between revisions
missed out binary_exp in list edit
(factorised out function exp_factor to improve structure) |
(missed out binary_exp in list edit) |
||
Line 466:
Mod > 0 ->
binary_exp_mod(Base,Exp,Mod).
binary_exp(Base,Exponent) ->
binary_exp(Base,Exponent,1).
binary_exp(_,0,Result) ->
Result;
binary_exp(Base,Exponent,Acc) ->
binary_exp(Base*Base,Exponent bsr 1,Acc * exp_factor(Base,Exponent)).
binary_exp_mod(Base,Exponent,Mod) ->
|