0
$\begingroup$

I am sure I am missing something trivial :-( Still any help is welcome.

ec1[c1_, c2_] := 1/c1
ec2[c1_, c2_] := 1/c2
Bcom[b_, c1_, c2_] := ec1[c1, c2] - (ec1[c1, c2] - ec2[c1, c2])

 X = {}
 For[a = 10, a < 100, a += 10,
   For[i = 1, i < 100, i += 5,
     For[j = i + 1, j <= 50, j += 4,
       AppendTo[X, {Bcom[a, i, j]}]]]]
$\endgroup$

closed as off-topic by Henrik Schumacher, rhermans, m_goldberg, garej, Öskå Jul 22 at 6:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Henrik Schumacher, rhermans, m_goldberg, garej, Öskå
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ It is. Check X. Afterwards. $\endgroup$ – Henrik Schumacher Jul 17 at 19:20
3
$\begingroup$

Try

ec1[c1_, c2_] := 1/c1
ec2[c1_, c2_] := 1/c2
Bcom[b_, c1_, c2_] := ec1[c1, c2] - (ec1[c1, c2] - ec2[c1, c2])

X = {};
For[a = 10, a < 100, a += 10,
  For[i = 1, i < 100, i += 5,
   For[j = i + 1, j <= 50, j += 4,
    AppendTo[X, {Bcom[a, i, j]}]
    ]]];
X

Or more idiomatic in Mathematica and taking 60% of the time

X2=Flatten[Table[
  {Bcom[a, i, j]}
  , {a, 10, 100 - 10, 10}
  , {i, 1, 100 - 5, 5}
  , {j, i + 1, 50, 4}
  ], 2];

Check the result is the same

X===X2
(* True *)
$\endgroup$
  • $\begingroup$ Just too tired... Thank you $\endgroup$ – user34047 Jul 17 at 19:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.