The k-multifactorial of n is denoted by fac[k]
(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:
fac[k]
(n) = n, if k ≥ n;
fac[k]
(n) = n * fac[k]
(n – k), if k < n;
You will be given n and k and have to evaluate the value of fac[k]
(n). If the result is strictly greater than 10^18
, you must print "overflow".
Two integers n and k (1 ≤ n, k ≤ 2 * 10^9
).
Print the value of fac[k]
(n). If it is strictly greater than 10^18
, print "overflow".