Sum of n natural numbers

why the print statement is written outside the loop can we write it inside the loop

you can , but then u ll print the value after each summation
like for 3 it ll be
1
3
6