https://inst.eecs.berkeley.edu/~cs61a/fa21/hw/hw07/#q3-pow