CMIMC 2017 Power Problem 15

Find the number of comparisons this algorithm always makes