For Loop Problem in Mathematica

  1. Hello,
    I want to execute a multiline code for each value of the for loop. How can I do that?
    Regards
     
  2. jcsd
  3. For[
    i = 0, i < n, i++,
    line1;
    line2;
    line3
    ]
     
  4. Thanks DaleSpam. I used ',' instead of ';', which was not accepted by Mathematica. This saves a lot of effort.
    Best regards
     
  5. No problem. You can always use ; to make a compound statement, so it is a general trick that helps elsewhere too.
     
Know someone interested in this topic? Share a link to this question via email, Google+, Twitter, or Facebook

Have something to add?