← Questions

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

0
AbridgeCodingLast asked Sep 2026

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.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding