Re: AGAIN Nested while loop!!!

• To: mathgroup at smc.vnet.net
• Subject: [mg71646] Re: AGAIN Nested while loop!!!
• From: dh <dh at metrohm.ch>
• Date: Sat, 25 Nov 2006 05:37:35 -0500 (EST)
• References: <ek63rd\$907\$1@smc.vnet.net>

```Hi,
you got the syntax of "If" wrong. This works:
result={};
For[i=1,i<=6,i++,
For[j=i+1,j<=6,j++,
If[lst[[i]]==lst[[j]],result={i,j};Break[]]]
];
result
Concerning the While loop, the logic is wrong. This works:
result = {};
i = 0;
While[++i <= 6,
j = i;
While[++j <= 6, If[lst[[i]] == lst[[j]], result = {i, j}; Break[]]
]
];
result
Daniel

mumat wrote:
> 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,
>