z-factorials
N factorial (N!) is defined as the product of all the numbers from N to 1, N•(N-1)•(N-2)• ..... •3•2•1. And is written as N!. Sometimes we need to find a product of every other or every Kth number from the range (N to 1).. We will denote this as N!! (every other element) or N!!...! (every K-th), where we have ! K times after N.
For K>=2 we can have two different cases:
FIRST, when N is divisible by K then we multiply every K-th number all the way to K, and
SECOND, when N is not divisible by K, then we multiply every K-th number all the way to N mod K.
For example:
3! = 3•2•1;
10!!! = 10•7•4•1.
8!! = 8•6•4•2.
Remark: The tests will be chose so that the result will not be greater than 2000000000.
11!!!Output:
8807!!Output:
105Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.