Re: nesting while function
- To: mathgroup at smc.vnet.net
- Subject: [mg56793] Re: [mg56758] nesting while function
- From: DrBob <drbob at bigfoot.com>
- Date: Fri, 6 May 2005 03:00:03 -0400 (EDT)
- References: <200505051001.GAA22002@smc.vnet.net>
- Reply-to: drbob at bigfoot.com
- Sender: owner-wri-mathgroup at wolfram.com
You forgot to initialize j in the outer loop:
t = 0; i = 1;
While[i â?¤ 3,
j = 1;
While[j â?¤ 2, t++; j++];
i++]
t
6
Bobby
On Thu, 5 May 2005 06:01:57 -0400 (EDT), <marloo3 at mail15.com> wrote:
> 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
>
>
>
>
>
>
>
--
DrBob at bigfoot.com
- References:
- nesting while function
- From: marloo3@mail15.com
- nesting while function