Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'While-Loop inside Module doesn't work' topicStudent Support Forum > General > "While-Loop inside Module doesn't work"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
xavier
12/19/12 09:16am

I found one mistake: product had to be termed inside the brackets at the beginning of the Module-segment.

faculty[x_] := Module [{u;product},
product = 1;
u = 1;
While[u <= x,
product = product*u;
u = u + 1
](*While*)
](*Module*)
faculty[3]

Now I get the following output:

Module::lvsym: Local variable specification {u;product} contains u;product, which is not a symbol or an assignment to a symbol. >>


So I think the While-Loop is not the big problem. But I don't understand why Mathematica tells me that u is not a symbol (and product also not). Can anyone help?

Thank you very much!
Xavier

URL: ,

Subject (listing for 'While-Loop inside Module doesn't work')
Author Date Posted
While-Loop inside Module doesn't work xavier 12/18/12 12:33pm
Re: While-Loop inside Module doesn't work xavier 12/19/12 09:16am
Re: Re: While-Loop inside Module doesn't work jf 12/19/12 10:37am
Re: Re: While-Loop inside Module doesn't work Bill Simpson 12/19/12 10:36pm
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic