Geek is getting really fat. He wants to lose his weight but can't get the motivation to workout. Seeing this, his friend  Heisenberg offers him a deal.
For every K pushups Geek does, Heisenberg will give him money equal to the number of pushups Geek has done till then (Refer Example for Explanation).
Find out the amount of money he made if he does N pushups.
Example 1:
Input: N = 5, K = 2
Output: 6
Explanation: Pushup 1: No Money, Pushup 2: 
+2 Pushup 3: No Money, Pushup 4: +4 and 
Pushup 5: No Money.
Example 2:
Input: N = 5, K = 3
Output: 3
Explanation: Pushup 1: No Money, Pushup 2: 
No Money, Pushup 3: +3, Pushup 4: No Money 
and Pushup 5: No Money.
 
Your Task: 
You don't need to read or print anything. Your task is to complete the function total_Money() which takes N and K as input parameter and returns the amount that Ishan can make.
Expected Time  Complexity: O(1)
Expected Space Complexity: O(1)
 
Constraints:
1 <= N <= 10^{9}
1 <= K <= 10^{5}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3



class Solution:

	def total_Money(self, n, k):

		# Code here

Solutions:
class Solution:

	def total_Money(self, n, k):
		a = n // k
		b = a * k
		return int(a / 2 * (2 * k + (a - 1) * k))


class Solution:

	def total_Money(self, n, k):
		t = n // k
		return k * (t * (t + 1) // 2)


class Solution:

	def total_Money(self, n, k):
		p = n // k
		return p * (p + 1) * k // 2


class Solution:

	def total_Money(self, n, k):
		money = 0
		step = n // k
		return int(k * step * (step + 1) / 2)


class Solution:

	def total_Money(self, n, k):
		N = n // k
		return int((2 * k + (N - 1) * k) * (N / 2))


class Solution:

	def total_Money(self, n, k):
		x = (n - k) // k + 1
		return x * (2 * k + (x - 1) * k) // 2
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		(n, k) = input().split()
		n = int(n)
		k = int(k)
		ob = Solution()
		ans = ob.total_Money(n, k)
		print(ans)


class Solution:

	def total_Money(self, n, k):
		sum = n // k
		return sum * (2 * k + (sum - 1) * k) // 2


class Solution:

	def total_Money(self, n, k):
		x = n // k
		s = x * (2 * k + (x - 1) * k) // 2
		return s


class Solution:

	def total_Money(self, n, k):
		x = n // k
		sum1 = x * (2 * k + (x - 1) * k) // 2
		return sum1


class Solution:

	def total_Money(self, n, k):
		x = n // k
		sum_ = x * (2 * k + (x - 1) * k) // 2
		return sum_


class Solution:

	def total_Money(self, n, k):
		if n < k:
			return 0
		f = int(n / k)
		z = k + (f - 1) * k
		return int((k + z) * f / 2)