Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: What is going on!?!

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104727] Re: [mg104688] What is going on!?!
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sun, 8 Nov 2009 06:44:49 -0500 (EST)
  • Reply-to: hanlonr at cox.net

The output of the For is Null (from documentation on For: "Unless an explicit Return is used, the value returned by For is Null."). When multiplied by x (i.e., 10) gives 10*Null. Put the semi-colon after the right bracket.

x = 0;
For[i = 1, i <= 10, i++, x = x + 1]; x

10


Bob Hanlon

---- Joe Hays <joehays at vt.edu> 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



  • Prev by Date: Re: find subsets
  • Next by Date: Re: What is going on!?!
  • Previous by thread: Re: Re: What is going on!?!
  • Next by thread: Re: What is going on!?!