# Animation Nodes - calculate factorial of frame numbers

First of all, this is of course not my project. I am working on a project that has a similar idea and i want that for the sake of clarification. to briefly explain what i want, i need implementing the following simple pseudo program with animation node syntax

frame_number=0,frame_factorial=1
while(1)
{
frame_number++;
frame_factorial*= frame_number;
}


So perhaps the simplest way to do it, is to create a math node with multiply mode, connection time info(frame number) to one input, then connecting the result back to the other input(feedback), which certainly doesn't work with animation node's syntax. so the question is how to retain a certain value calculated in a certain frame, in order to be used in the next frame? or when you have a cumulative calculation, like the one above?

for instance i thought the only way for that is to put 2 python script nodes at the beginning and at the end of a frame iteration, then use the script node at the end to save data to, for instance, csv file, then in the next frame read data from that csv file. however this is an impractical and unreasonable solution, i think their are of course other more practical methods, built in with animation nodes, isn't it?

I think you'd just be better off with an Expression node (Shift + A > Subprograms > Expression) with a Float input and the code factorial(x). It looks like this: