Power exponentiation

whats the logic behind calculating f(n)=1n∗2n−1∗3n−2∗…∗n1

1 Like

if it is related to the last day contest, then it is superfactorial concept!!
you can search about it on the internet

We know f(1) = 1, f(2) = 1x1x2
Consider f(3) , f(4), f(5) values.
f(3)=1x1x1x2x2x3 which is nothing but
f(3)=(1x2x3) x(1x1x2) when rewritten, similarily
f(4)=1x1x1x1x2x2x2x3x3x4 when rewritten,
f(4)=(1x2x3x4) x(1x1x1x2x2x3) =(1x2x3x4) x((1x2x3)x(1x1x2))
f(5) =1x1x1x1x1x2x2x2x2x3x3x3x4x4x5
When rewritten just like f(4) we get
f(5)=(1x2x3x4x5) x((1x2x3x4)x((1x2x3)x(1x1x2)))
Now, on observing those values, we get
f(n) = n! x f(n-1)
Thats it
Hope it helps.

1 Like

For any ‘i’, answer is:-

f(i) = f(i-1)*(1*2*3*4.....*i)

Pre-compute these values and you are done.


Refer this code.:slightly_smiling_face:

The Function simply imlies:
that’s it
thank you

1 Like