Problems
Multifactorial
Multifactorial
The k-multifactorial of n is denoted by fack
(n) and is defined as the product of every positive number of the form n – k * x, x = 0, 1, 2, … .
A formal definition of multifactorial is:
fack
(n) = n, if k ≥ n;
fack
(n) = n * fack
(n – k), if k < n;
You will be given n and k and have to evaluate the value of fack
(n). If the result is strictly greater than 1018
, you must print "overflow".
Input
Two integers n and k (1 ≤ n, k ≤ 2 * 109
).
Output
Print the value of fack
(n). If it is strictly greater than 1018
, print "overflow".
Input example #1
14 3
Output example #1
12320
Input example #2
1000 2
Output example #2
overflow