[Solved] Factorial Math Function

Hi all,
I try to create a loop to calculate Factorial math function…
It works sometimes but the mathematical calculation can change and I don’t know why. May be it’s due to the type of the variable (numeric vs text) ?? Is it possible to change the text variable into a numeric variable to be sure that the calculation is good ?
Do you have another idea why the calculation can change ?

In the screen you can see the loop to calculate the factorial of the sum 1, 2, 3 and 4.
And the result…

The sum of the row 1 is 2 (Tot A = 1 + 1) and correct and the factorial gives 6
The sum of the row 2 is 4 (Tot B = 2 + 2) and correct but the factorial gives 360 !!!

If you want to ensure that a text variable is interpreted as a number, add 0 to it. That will convert the value to a scalar.

That said, with your loops, you keep multiplying a variable (‘ap’, ‘bp’, ‘cp’, etc) by a coefficient and assigning it back to itself. The question is: how do you ensure that “ap” does not have a pre-existing value? Do you start by initializing them to 1 before multiplying with anything?

Thanks for your answer.
Yes I have a Function before to run the loop Which initialize each variable to 1 :frowning:


Get Factorial


Respect :flushed:
I will try this.

May be I missed something… When I try to run your procedure, the result is one… Where is my mistake ?
TEFA is my Input field
label44 my label
ap is my variable (-> number)


Instead of variables from function parameters, you use problem blocks of global variables.

I’m sorry, I don’t understand…
Need I use another variable ? AP is not the good one ?


I see the getfactor different… This module is not in the function one ?

Terrible… I will try…

It’s ok now…

@franckled, I’ve merged you 3 responses into a single post.

For future reference, if you have updates or amendments to make to a post in the community, please use the Edit button :pencil2: on your post.


1 Like