Loop Invariants
Hey, this seems like an application of induction. You choose some property you want to prove about your program, show it is true before the loop (base case), then show it remains true for any next iteration (inductive step), therefore it is true for all iterations.<p>It reminds me of the hand-wavy inductive proofs I run through my head when I write recursive functions. Usually it&#x27;s not even about eliminating bugs, it&#x27;s just the most natural way to understand why the code works. It seems less natural for imperative for&#x2F;while loops but still a good tool to keep in mind.