Sum of First K MultiplesEasy

Sum of First K Multiples

EasyPractice library · +10 XPdynamic programmingarithmetic progressioniteration

Given two positive integers, N and K, find the sum of the first K multiples of N. The multiples are N1, N2, N3, ..., NK.

Input

A single line containing two space-separated integers N and K.

Output

A single integer representing the sum of the first K multiples of N.

Constraints

1 <= N, K <= 1000

Time limit 1 s (native code; slower languages get more)Memory 256 MB13 hidden tests

Example 1

Input
3 4
Output
30

The first 4 multiples of 3 are 3, 6, 9, 12. Their sum is 3 + 6 + 9 + 12 = 30.

Example 2

Input
5 1
Output
5

The first 1 multiple of 5 is 5. Its sum is 5.

Hints