# Why do I not see any results from my For-loop? [closed]

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


## 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.

• It is. Check X. Afterwards. – Henrik Schumacher Jul 17 at 19:20

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 *)

• Just too tired... Thank you – user34047 Jul 17 at 19:33