For Loop Problem in Mathematica

  • Mathematica
  • Thread starter EngWiPy
  • Start date
  • #1
1,367
61
Hello,
I want to execute a multiline code for each value of the for loop. How can I do that?
Regards
 

Answers and Replies

  • #2
Dale
Mentor
Insights Author
2020 Award
31,083
7,762
For[
i = 0, i < n, i++,
line1;
line2;
line3
]
 
  • #3
1,367
61
For[
i = 0, i < n, i++,
line1;
line2;
line3
]

Thanks DaleSpam. I used ',' instead of ';', which was not accepted by Mathematica. This saves a lot of effort.
Best regards
 
  • #4
Dale
Mentor
Insights Author
2020 Award
31,083
7,762
No problem. You can always use ; to make a compound statement, so it is a general trick that helps elsewhere too.
 

Related Threads on For Loop Problem in Mathematica

Replies
2
Views
5K
Replies
8
Views
7K
Replies
2
Views
4K
Replies
2
Views
3K
Replies
11
Views
4K
  • Last Post
Replies
3
Views
2K
Replies
1
Views
3K
Replies
12
Views
2K
Replies
5
Views
13K
Top