Sum of numbers up to n divisible by 3, 5 or 7
Given a positive integer n, return the sum of every integer from 1 to n that is divisible by at least one of 3, 5 and 7, counting each number once. A loop works; then do it in constant time with arithmetic series and inclusion-exclusion.
No answer yet. Write the first one; the best answer gets endorsed.
