Updated functions to use repeated multiplication rather than recursive calls.