In python / numpy - there is a way to build an expression containing factorials, but since in my script many factorials will be duplicated or reduced, wait until I specify the runtime to calculate it.
Let's say F(x) := x!
And I create an expression like (F(6) + F(7)) / F(4)
- I can speed it up significantly, even do it in my head by doing
(F(6) * (1 + 7)) / F(4)
= 5 * 6 * 8
= 240
Basically, I’m going to generate such expressions and would like the computer to be smart and not calculate all factorials by multiplying by 1, that is, using my example, we don’t actually execute
(6*5*4*3*2 + 7*6*5*4*3*2) / 4*3*2
I really started developing the Factorial class, but I'm new to python and numpy, and I was wondering if this is a problem that has already been resolved.