For Loop Problem in Mathematica

  • Mathematica
  • Thread starter EngWiPy
  • Start date
  • #1
1,367
61

Main Question or Discussion Point

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
28,904
5,168
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
28,904
5,168
No problem. You can always use ; to make a compound statement, so it is a general trick that helps elsewhere too.
 

Related Threads for: For Loop Problem in Mathematica

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