Practice Divisible and Non-divisible Sums Difference
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Among integers 1 through n inclusive, compute the sum of values not divisible by m and the sum of values divisible by m. Return the first sum minus the second.
Source: Divisible and Non-divisible Sums Difference on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
n = 10, m = 3
Output
19
# Example 2
Input
n = 5, m = 6
Output
15
# Example 3
Input
n = 5, m = 1
Output
-15
Constraints
1 <= n, m <= 1000
Related LeetCode Problems
Practice more problems similar to Divisible and Non-divisible Sums Difference.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.