MathGroup Archive 2008

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

Search the Archive

Re: Help with "If" statement within "Table"

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90537] Re: Help with "If" statement within "Table"
  • From: Diana <diana.mecum at gmail.com>
  • Date: Sat, 12 Jul 2008 05:32:01 -0400 (EDT)
  • References: <g56t9c$3qo$1@smc.vnet.net>

Math folks,

I should have supplied more information.

My initialization was as follows.

A136164 = {0, 2, 2, 2, 2, 3, 2, 2, 2, 3, 2}

A136164 = PadRight[A136164, 1000, 2];

Table[If[CoprimeQ[Divisors[n][[j]], Divisors[n][[j - 1]]] ||
    CoprimeQ[Divisors[n][[j]], Divisors[n][[j + 1]]],
   A136164[[n]] = A136164[[n]] + 1], {j, 3, Length[Divisors[n]] - 2}];

It turns out that I can simply replace the Table statement with a Do
statement, and the A136164 list gets updated.

Do[If[CoprimeQ[Divisors[n][[j]], Divisors[n][[j - 1]]] ||
    CoprimeQ[Divisors[n][[j]], Divisors[n][[j + 1]]],
   A136164[[n]] = A136164[[n]] + 1], {j, 3, Length[Divisors[n]] - 2}];

Thanks all for your responses.

Diana M.


  • Prev by Date: Re: Writing to an External file, ie .txt
  • Next by Date: Stop iteration iconstructing Table
  • Previous by thread: Re: Help with "If" statement within "Table"
  • Next by thread: Re: Help with "If" statement within "Table"