Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: AGAIN Nested while loop!!!

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71615] Re: [mg71594] AGAIN Nested while loop!!!
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sat, 25 Nov 2006 05:36:53 -0500 (EST)
  • Reply-to: hanlonr at cox.net

lst = Table[Random[Integer, {i, 50}], {i, 6}]

{11,30,44,28,50,31}

So that the result has a consistent structure in either case, I would recommend that the output be {True, {}} or {False, {pairs}}

Needs["DiscreteMath`Combinatorica`"];

Module[{sel=Select[KSubsets[lst,2], 
        Mod[#.#,5]==0&]},
  {Length[sel]==0,sel}]

{False, {{11, 28}, {30, 50}, {44, 28}, {28, 31}}}


Bob Hanlon

---- mumat <csarami at gmail.com> 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,
> 
> chekad
> 


  • Prev by Date: Area of ellipse between major axis and ray through focus, given angle
  • Next by Date: Re: Converting an expression to a list of terms?
  • Previous by thread: Re: AGAIN Nested while loop!!!
  • Next by thread: Re: AGAIN Nested while loop!!!