| Author |
Comment/Response |
xavier
|
12/18/12 12:33pm
I am a mathematica newbee. I wanted to write a procedure which evaluates the faculty of a natural number (I only want that procedure so that I get used to the mathematica modules; so I know how to code a simpler program which solves this).
This is my code:
faculty[x_] := Module [{u},
product = 1;
u = 1;
While[u <= x,
product = product*u;
u = u + 1
](*While*)
](*Module*)
faculty[3]
If I run that program I don't get any output. I wanted Mathematica to print 6 (which is the same as 3!).
Until now I have never seen a Module with a While-Loop inside. Is there any reason why While can't be used inside a Module?
I am very thankful for every help!
xavier
URL: , |
|