Re: nesting while function
- To: mathgroup at smc.vnet.net
- Subject: [mg56779] Re: [mg56758] nesting while function
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Fri, 6 May 2005 02:59:47 -0400 (EDT)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
You need to reset j within the outer loop t=0; i=1; While[i<=3, j=1; While[j<=2, t=t+1; j=j+1]; i=i+1]; t 6 Bob Hanlon > > From: marloo3 at mail15.com To: mathgroup at smc.vnet.net > Date: 2005/05/05 Thu AM 06:01:57 EDT > Subject: [mg56779] [mg56758] nesting while function > > Hi > t = 0; i = 1; j = 1; > While[i <= 3, > 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 > > > > >