MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: What is going on!?!

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104759] Re: What is going on!?!
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Sun, 8 Nov 2009 06:52:10 -0500 (EST)

On 11/7/09 at 6:46 AM, joehays at vt.edu (Joe Hays) wrote:

>Can anyone tell me why the output is not a simple "10" instead of
>"10 Null"?

>In[3]:= x = 0; For[i = 1, i <= 10, i++,
>x = x + 1;
>]x

>Out[4]= 10 Null

Per the documentation, For returns Null. So For[....] x
evaluates to x times Null which is what you got. If you want
simply the result then change the code to be:

=46or[i = 1, i <= 10, i++,
   x = x + 1;
   ]; x

Or even better

Sum[n,,{n,10}]



  • Prev by Date: Simplification problem
  • Next by Date: Re: How can I reduce the frequency of a sine wave tia sal22
  • Previous by thread: Re: What is going on!?!
  • Next by thread: Re: What is going on!?!