No, it does not work. Suppose k = 2.
Since power(3.0, 2) finds that k is even,
it selects the second case. It computes
power(3.0, 1), which returns 3.0. Then it calls
power(3.0, 2) to do the squaring. So
power(3.0, 2) calls power(3.0, 2). It is
an infinite recursion.