Divisible and Non-divisible Sums Difference Problem

Divisible and Non-divisible Sums Difference Problem — ExecCode Easy DSA Practice

Solve the Divisible and Non-divisible Sums Difference problem on ExecCode. Free online easy DSA practice in Math. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given positive integers n and m. Your task is to compute the required answer and return the integer num1 - num2. Define two integers as follows: - num1: The sum of all integers in the range [1, n] (both inclusive) that are not divisible by m. - num2: The sum of all integers in the range [1, n] (both inclusive) that are divisible by m.

Examples

Input {"n": 10, "m": 3}; Output 19. Input {"n": 5, "m": 6}; Output 15

Constraints

1 <= n, m <= 1000

Practice Divisible and Non-divisible Sums Difference free on ExecCode. Browse DSA problems, topic map, and placement guides.