Can someone explain why i ranges from -3 to 3 in the output of Do[Print[{i, j}], {i, -3, 3}], but not in Do[Print[{i, j}], {i, -3, 3},{j,-i,i}]?

I was thinking for the second input I would get {-3,-3}, {-3,-2} ... {3,3}, but the output starts with i=0 and goes to i=3 no negative values of i are printed, however j does iterate from -i to i.

  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – Michael E2
    Dec 12, 2014 at 3:26

1 Answer 1


The output of Do[Print[j], {j, 3, -3}] is empty. That is what you are doing for the first few iterations of the outer loop (the loop over i) in the statement you are asking about.

The output of Do[Print[j], {j, 3, -3, -1}] is a sequence of integers from 3 to -3, inclusive, one per line.

If you entered Do[Print[{i, j}], {i, -3, 3}, {j, -i, i, -1}] you would have gotten the other half of the table that you expected, with the output "{0,0}" appearing in both halves.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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