Difference b/w 2 fast exponentiation methods

There are 2 ways to achieve fast exponentiation. One told in Mathematics section and other told in Bitmasking. Which is to be used when ? Because both are O(logN).

LINK- https://codeshare.io/5wLWDK

@anuj_it
hello Anuj,
iterative is faster than recurvive because recursive modular exponentiation involves function call

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.