So I have this assignment:
I need help with question 2.
I thought I knew how to do it, when I realized the factorials are being computed backwards. The algorithm is correct intuitively, but I can’t seem to find a loop invariant that holds true before the loop starts.
I’m confused. Thanks.
Hint. It does not change the result of the algorithm if you add
z <- ybefore the loop begins. Does that make your loop invariant easier to find?