MathGroup Archive 2008

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

Search the Archive

Help with "If" statement within "Table"

  • To: mathgroup at
  • Subject: [mg90500] Help with "If" statement within "Table"
  • From: Diana <diana.mecum at>
  • Date: Fri, 11 Jul 2008 02:02:26 -0400 (EDT)


I am trying to write a small program to count the number of divisors
of a number which have at least one coprime neighbor, and secondly the
number of divisors which have two coprime neighbors, (one on each

For example, the divisors of 60 are {1, 2, 3, 4, 5, 6, 10, 12, 15, 20,
30, 60}. 6 of the divisors have at least one coprime neighbor, and 5
of the divisors have two coprime neighbors.

In doing this, I have written the following statement. "n" is the
number for which I am calculating divisors, and "A136164" is my first
list, the of number of divisors in the "at least one neighbor" case.
For some reason, A136164 is not updating when the "If" statement is
executed within the "Table" statement. Can someone help me? Thanks,
Diana M.

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}];

  • Prev by Date: Re: Almost symbolic computations (?)
  • Next by Date: Re: Symbol function, a question
  • Previous by thread: Re: ListPlot still ignores SetOptions[] command
  • Next by thread: Re: Help with "If" statement within "Table"