#148
The Big Divide
 

Difficulty:Medium
Topics:math


Write a function which calculates the sum of all natural numbers under n (first argument) which are evenly divisible by at least one of a and b (second and third argument). Numbers a and b are guaranteed to be coprimes.

Note: Some test cases have a very large n, so the most obvious solution will exceed the time limit.


test not run
(= 0 (__ 3 17 11))
test not run
(= 23 (__ 10 3 5))
test not run
(= 233168 (__ 1000 3 5))
test not run
(= "2333333316666668" (str (__ 100000000 3 5)))
test not run
(= "110389610389889610389610"
  (str (__ (* 10000 10000 10000) 7 11)))
test not run
(= "1277732511922987429116"
  (str (__ (* 10000 10000 10000) 757 809)))
test not run
(= "4530161696788274281"
  (str (__ (* 10000 10000 1000) 1597 3571)))


Code which fills in the blank: