Tap here to switch tabs
Problem
Submissions

Problem: Divisible and Non-divisible Sums Difference

med
30 min
Try to solve the Divisible and Non-divisible Sums Difference problem.

Statement

You are given two positive integers, n and m.

Define two values, num1 and num2, as follows:

  • num1 is the sum of all integers in the range [1,[1, n]] that are not divisible by m.

  • num2 is the sum of all integers in the range [1,[1, n]] that are divisible by m.

Return the result of num1 minus num2.

Constraints:

  • 1≤1 \leq n, m ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Divisible and Non-divisible Sums Difference

med
30 min
Try to solve the Divisible and Non-divisible Sums Difference problem.

Statement

You are given two positive integers, n and m.

Define two values, num1 and num2, as follows:

  • num1 is the sum of all integers in the range [1,[1, n]] that are not divisible by m.

  • num2 is the sum of all integers in the range [1,[1, n]] that are divisible by m.

Return the result of num1 minus num2.

Constraints:

  • 1≤1 \leq n, m ≤1000\leq 1000