Share your repls and programming experiences

← Back to all posts
recalculating in a loop
vk2fgav (0)

Due to how a for loop works, "i < element" is run each cycle, and therefor if "element--" is run inside of the loop, the upper bound of the loop is reduced each time its run. This means that a Bounds of 10 will reduce to 5, as i goes from 0 -> 4, making the loop complete after only the 5th pass.