set a to 3
set b to 5
set bound to 1000
set the_list to {}
set the_sum to 0
repeat with i from 1 to 1000
set this_a to a * i
set this_b to b * i
if this_a < bound then set the_sum to (the_sum + this_a)
if this_b < bound then set the_sum to (the_sum + this_b)
set this_ab to a * b * i
if this_ab < bound then set the_sum to (the_sum - this_ab)
end repeat
return the_sum