You need to put the variables x and fact inside of your function. Since they’re not in the function, they’re in a global scope. This means that after you run your factorialize function, x and fact are set to a new value, and they remain at that value after the function finishes. So using your code, if I do factorialize(5) I get 120, which is correct. But if afterwards I do factorialize(3), I get 120.
I get 120 because fact is still 120 since it’s a global variable. X is also set to 5, so it doesn’t do any calculations (since I passed 3 in as an argument it won’t even bother doing anything).
Move the variables inside of the function so their scope is only inside of the function. So once the function finishes, the variables will basically be destroyed when the function returns.