Re: Re: nesting while function
- To: mathgroup at smc.vnet.net
- Subject: [mg56822] Re: [mg56799] Re: nesting while function
- From: Namrata Khemka <namrata.khemka at gmail.com>
- Date: Sat, 7 May 2005 04:16:34 -0400 (EDT)
- References: <d5cst9$m3a$1@smc.vnet.net> <200505060700.DAA06174@smc.vnet.net>
- Reply-to: Namrata Khemka <namrata.khemka at gmail.com>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, You forgot to initialize the value of j In[1]:= t = 0; i = 1; While[i <= 3, j=1; While[j <= 2, t = t + 1; j = j + 1]; i = i + 1] t Out[3]= 6 > marloo3 at mail15.com wrote: > > Hi > > t = 0; i = 1; j = 1; > > While[i <= 3, > > j=1; > > > While[j <= 2, > > t = t + 1; > > j = j + 1]; > > i = i + 1] > > > > give the result for t=2 and not 6 as should be > > > > but > > t = 0; Do[ > > Do[ > > t = t + 1; > > , {j, 2}]; > > , {i, 3}] > > > > give the value of 6 for t > > is this a wrong behaviour for the "While" function ? or i miss something. > > thanks > > > >
- References:
- Re: nesting while function
- From: Peter Pein <petsie@dordos.net>
- Re: nesting while function