how to find loop invariant site:stackoverflow.com - Search