ADVANCED: Factorial (factorial)
Create a macrofilter which computes a factorial for a given value.
The function argument should be provided as Integer.
Single integer for which factorial value should be computed.
Factorial value of the input value.
This exercise should be solved using macrofilter's registers. All computed steps should be accumulated in a single macrofilter register.
Create the Task macrofilter which computes factorial value using the internal EnumerateIntegers filter.
Create a new Task macrofilter in PROCESS section and name it Factorial.
Create an input inN of type Integer.
Enter to the Factorial macrofilter and add a new register regFactorial of type Long. Set its default value to 1 as on the image below.
Configuring a macrofilter's register:
Connect macrofilter's input inN with inCount.
Add a new Formula into the macrofilter's PROCESS section and connect outValue to it.
Connect prevFactorial to the formula.
Create a new output in the formula named outNextFactorial:
outNextFactorial = inValue * inPrevFactorial
Create a new macrofilter's output named outValue of type Long.
Connect the outNextFactorial formula's output with the macrofilter's outputs: nextFactorial and outValue.
Set a default output value of the outValue output to 1. This value will be set on the output when any iteration of the internal loop was performed.
Macrofilter Factorial computes a factorial value to using its registers.