Message Boards Message Boards

0
|
658 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Writing a list in format {m[1],0,a1},...{m[k],1,ak}

I need to write something as {m[1],0,a1},...{m[k],1,ak}

2 Replies

Thank you very much. You introduce me at another level of programation. Happiness

You have to play with the order of evaluation. Here is a way:

Clear[p];
p[n_, k_] := Apply[Sum,
  {IntegerPart[(2 + n -
       Sum[i  m[i], {i, 3, k}])/2],
   Sequence @@ Table[
     {m[k - l],
      IntegerPart[(k - l)/k],
      (n - Sum[(s)  m[s],
          {s, k - l + 1, k}])/(k - l)},
     {l, 0, k - 3}]}]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract