Skip to content

Practice Sum Multiples

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2652
LeetCode Problem

Sum Multiples

Problem Statement

Given a positive integer n, find the sum of all integers in the range [1, n] inclusive that are divisible by 3, 5, or 7. Return an integer denoting the sum of all numbers in the given range satisfying the constraint.

Source: Sum Multiples on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 7
Output
21

# Example 2

Input
n = 10
Output
40

# Example 3

Input
n = 9
Output
30

Constraints

1 <= n <= 10^3

Related LeetCode Problems

Practice more problems similar to Sum Multiples.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.