For loop not giving the correct output

Printable View