MathGroup Archive 2006

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

Search the Archive

Re: AGAIN Nested while loop!!!

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71605] Re: AGAIN Nested while loop!!!
  • From: Peter Pein <petsie at dordos.net>
  • Date: Sat, 25 Nov 2006 05:36:40 -0500 (EST)
  • References: <ek63rd$907$1@smc.vnet.net>

mumat schrieb:
> I have a list of numbers
> 
> lst = Table[Random[Integer, {i, 50}], {i, 6}]
> 
> I want to write a program that if There are two numbers x, y in A where
> 
> 
> Mod[x^2+y^2, 5]==0  reuturn False and the pair {x,y}, otherwise True!
> 
> 
> For[i = 0, i < 6, For[j = i, j < 6,
>   If[Mod[lst[[i]]^2 + lst[[j]]^2, 3] == 0,
> Return[False,{i,j}]];Break[], j++], i++]
> 
> While loop and nested while loops accept only one counter "i".
> 
> i=1;j=2;
> 
> While[i<6 && While[j<6 &&
> Mod[lst[[i]]^2+lst[[j]]^2,7]=!=0,j++];i++];{i,j}
> 
> {2,6}
> 
> 
> Would be great if you could help me with this!!
> 
> 
> Regards,
> 
> chekad
> 

Do you mean something like

In[1]:=
lst = Table[Random[Integer, {i, 50}], {i, 6}]
Out[1]=
{32, 27, 32, 36, 5, 46}
In[2]:=
(Piecewise[{{#1, Mod[#1 . #1, 5] == 0}}, False] & ) /@
  Flatten[Outer[{#1, #2} & , lst, lst], 1]
Out[2]=
{False, False, False, {32, 36}, False, {32, 46},
  False, False, False,{27, 36}, False, {27, 46},
  False, False, False,{32, 36}, False, {32, 46},
  {36, 32}, {36, 27}, {36, 32}, False, False,
  False, False, False, False, False, {5, 5}, False,
  {46, 32}, {46, 27}, {46, 32}, False, False,
  False}

?


  • Prev by Date: Function Name from Inside the function
  • Next by Date: Re: pattern matching: rules that stop other rules?
  • Previous by thread: Re: AGAIN Nested while loop!!!
  • Next by thread: Re: AGAIN Nested while loop!!!