Why does loop order affect too much to execution time ?

Правка en1, от ExpectoPatronum, 2021-09-26 09:27:41
Code1
Code2

These code seem not to be differ too much but execution time have much differ. Example in case n = 500, code1 run in 3103ms but code 2 run only 789ms. What is the reason ? Pls explain to me. Thanks.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский ExpectoPatronum 2021-09-26 18:57:28 48
en2 Английский ExpectoPatronum 2021-09-26 18:56:10 101 Tiny change: ' << res;\n\n\n\n\n~~' -> ' << res;\n~~~~~\n\n\n\n~~'
en1 Английский ExpectoPatronum 2021-09-26 09:27:41 997 Initial revision (published)