The change made in function
expmod by Louis Reasoner will cause
expmode to be called twice in each recursive invocation.
The process becomes tree recursive as each invocation results in two branches. Clearly the height of the tree is where is the input to this procedure.
Also note that number of steps in the process is equal to total number of nodes in the tree.
Thus total nodes in the tree are .
Thus number of steps is equal to the input passed i.e. . As we can see this small mistake converted this code from complexity to order complexity.