Add all the natural numbers below one thousand that are multiples of 3 or 5.
Seems simple enough? Here’s my brute force way of answering it (using Python):
#initiate the counters n = 1 sumTo = 0 #iterate up to 1000, adding natural numbers that are multiples of 3 or 5 while n < 1000: if (n%3 == 0) or (n%5 == 0): sumTo = sumTo + n n = n + 1 else: n = n + 1 print (sumTo)
There’s probably a more elegant way of solving this, but hey, it’s a start! How would you solve it?