I have a problem how write the 'for' loop in mathematica:(adsbygoogle = window.adsbygoogle || []).push({});

my previous code looks like:

count=0;

flag=0;

step=100;

For i=1:1000

count=count+1;

if count>step

if flag== 0;

flag=1;

else

flag=0;

end

count=1;

end

if flag==0

p(i)=g

else

p(i)=-g

end

end

I need to rewrite this in mathematica but I do not know how.

Is it possible to write as a function, module or block?

thanks

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# How write the 'for' loop in mathematica

Loading...

Similar Threads - write 'for' loop | Date |
---|---|

LaTeX Bold Writing in Latex | Apr 16, 2017 |

LaTeX How to write the following in LaTeX | Oct 27, 2016 |

LaTeX How to Write This in Latex (in This Forums)? | May 19, 2016 |

How To Write Matrix In Latex? | Dec 13, 2015 |

How to Write Canceled Numbers in Word 2010? | Sep 9, 2015 |

**Physics Forums - The Fusion of Science and Community**