The code has
???? for the target sum. Replace
???? with
target (or
100) and click
Run Code to find all consecutive integer sets!
Notice the
break statement: once
sum > target, adding more positive integers can only increase the sum, so we immediately stop the inner loop and test the next starting integer.
Check Example 1 for a high-speed divisor-based method!