MathGroup Archive 2008

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

Search the Archive

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


On Jul 11, 2008, at 10:20 AM, Diana Mecum wrote:

> SSeziwa,
>
> Thanks. Yes, I did initialize the list as follows. I padded the  
> terms with 2's, and started with the 12th term.
>
> 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}];
>
> If I execute the "If" statement outside of the table, the sequence  
> elements are updated. For example,
>
> n=12
> j=3
> If[CoprimeQ[Divisors[n][[j]], Divisors[n][[j - 1]]] ||
>   CoprimeQ[Divisors[n][[j]], Divisors[n][[j + 1]]],
>  A136164[[n]] = A136164[[n]] + 1]
>
> With this, the sequence gets updated.

n doesn't have a value in your first set of statements.  Is this part  
of a larger program?

Regards,

Ssezi


  • Prev by Date: Stop iteration iconstructing Table
  • Next by Date: Re: Defining Functions and Simplifying Solutions
  • Previous by thread: Help with "If" statement within "Table"
  • Next by thread: Re: Help with "If" statement within "Table"