iterative exponentiation using successive squaring in ruby and scheme