Below I have my code that I created for finding the factorial of a number. The output I am getting when I enter MyFact[5]
is Null Return[120]
.
I am rather new to Mathematica so I feel its a small semantic problem, but any help would be appreciated!
MyFact[n_] :=
Module [
{
OneAgoFact,
MyNewFact,
Counter
},
MyNewFact = 1;
OneAgoFact = 1;
If[ n > 0,
Counter = 1;
While[Counter <= n,
MyNewFact = OneAgoFact*Counter;
OneAgoFact = MyNewFact;
Counter = Counter + 1;
]
]
Return[MyNewFact]
]
If[]
. If you do that, you can remove theReturn[]
. $\endgroup$