#C10350. Sum of Divisibles
Sum of Divisibles
Sum of Divisibles
Given two integers \(n\) and \(p\), compute the sum of all integers from 1 to \(n\) that are divisible by \(p\). Formally, if we denote \(m=\lfloor n/p \rfloor\), then the sum is given by:
\[ S = p \times \frac{m(m+1)}{2} \]
You are given multiple test cases. For each test case, output the corresponding sum.
Note: Use standard input and standard output to interact with the program.
inputFormat
The first line contains an integer \(T\) representing the number of test cases. Each of the following \(T\) lines contains two space-separated integers \(n\) and \(p\), where \(n\) is the upper bound and \(p\) is the divisor.
For example:
4 10 2 15 3 20 5 100 7
outputFormat
For each test case, print a single line containing the sum of all integers from 1 to \(n\) that are divisible by \(p\). Each output should be in a separate line.
For example, for the sample input above, the output should be:
30 45 50 735## sample
4
10 2
15 3
20 5
100 7
30
45
50
735
</p>