-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added README.md file for Divisible and Non-divisible Sums Difference
- Loading branch information
1 parent
f1f46c8
commit 6af311b
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
3172-divisible-and-non-divisible-sums-difference/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<h2><a href="https://leetcode.com/problems/divisible-and-non-divisible-sums-difference">Divisible and Non-divisible Sums Difference</a></h2> <img src='https://img.shields.io/badge/Difficulty-Easy-brightgreen' alt='Difficulty: Easy' /><hr><p>You are given positive integers <code>n</code> and <code>m</code>.</p> | ||
|
||
<p>Define two integers, <code>num1</code> and <code>num2</code>, as follows:</p> | ||
|
||
<ul> | ||
<li><code>num1</code>: The sum of all integers in the range <code>[1, n]</code> that are <strong>not divisible</strong> by <code>m</code>.</li> | ||
<li><code>num2</code>: The sum of all integers in the range <code>[1, n]</code> that are <strong>divisible</strong> by <code>m</code>.</li> | ||
</ul> | ||
|
||
<p>Return <em>the integer</em> <code>num1 - num2</code>.</p> | ||
|
||
<p> </p> | ||
<p><strong class="example">Example 1:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> n = 10, m = 3 | ||
<strong>Output:</strong> 19 | ||
<strong>Explanation:</strong> In the given example: | ||
- Integers in the range [1, 10] that are not divisible by 3 are [1,2,4,5,7,8,10], num1 is the sum of those integers = 37. | ||
- Integers in the range [1, 10] that are divisible by 3 are [3,6,9], num2 is the sum of those integers = 18. | ||
We return 37 - 18 = 19 as the answer. | ||
</pre> | ||
|
||
<p><strong class="example">Example 2:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> n = 5, m = 6 | ||
<strong>Output:</strong> 15 | ||
<strong>Explanation:</strong> In the given example: | ||
- Integers in the range [1, 5] that are not divisible by 6 are [1,2,3,4,5], num1 is the sum of those integers = 15. | ||
- Integers in the range [1, 5] that are divisible by 6 are [], num2 is the sum of those integers = 0. | ||
We return 15 - 0 = 15 as the answer. | ||
</pre> | ||
|
||
<p><strong class="example">Example 3:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> n = 5, m = 1 | ||
<strong>Output:</strong> -15 | ||
<strong>Explanation:</strong> In the given example: | ||
- Integers in the range [1, 5] that are not divisible by 1 are [], num1 is the sum of those integers = 0. | ||
- Integers in the range [1, 5] that are divisible by 1 are [1,2,3,4,5], num2 is the sum of those integers = 15. | ||
We return 0 - 15 = -15 as the answer. | ||
</pre> | ||
|
||
<p> </p> | ||
<p><strong>Constraints:</strong></p> | ||
|
||
<ul> | ||
<li><code>1 <= n, m <= 1000</code></li> | ||
</ul> |