Sum of numbers up to n divisible by 3, 5 or 7

0
Remix

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.

AbridgeOnline assessmentLast asked Sep 2026
No answer yet. Write the first one; the best answer gets endorsed.