If[] has priority over Repeat[], why?

Tang Dashi shared this question 6 years ago
Needs Answer

s=0


n=1

Repeate[100, SetValue[s,s+n], SetValue[n,n+1]]

I get s=5050, n=101. that's ok.

When I use

Repeate[100, If[s+n<500, SetValue[s,s+n]], SetValue[n,n+1]]

I get the same result. but I want s+n<500 finally.

If[] has priority over Repeat[], why?

© 2023 International GeoGebra Institute