# Loop statement inside an Exponential

**URL:** <https://community.wolfram.com/t/loop-statement-inside-an-exponential/1789>\
**Category:** Questions\
**Tags:** computer-science\
**Created:** [March 24, 2014, 12:28am UTC](https://community.wolfram.com/t/loop-statement-inside-an-exponential/1789 "2014-03-24T00:28:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sproubi1](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@sproubi1](https://community.wolfram.com/u/sproubi1)\
**Post date:** [March 24, 2014, 12:28am UTC](https://community.wolfram.com/t/loop-statement-inside-an-exponential/1789/1 "2014-03-24T00:28:18Z")

</div>

I’m trying to write a loop statement in Mathematica so that I get the output that looks a little something like this:  
{ 1, Exp[-I\*2\*Pi/5], Exp[-I\*2\*Pi\*2/ 5], Exp[-I\*2\*Pi\*3/5], Exp[-I\*2\*Pi\*4/5, …}.

Does anybody know what I must do to get it to give a simliar output above? The output doesn’t have to be exact; it can be in aproximate form (real part + imaginary part).

Thank you in advance.

```auto
k = 1;
A = 5;
a0 = 0;
a0 = a;
n = 4;
F0 = 0;
Do[F = F - I*2*Pi*k*(a)/(A); Print[Exp[F]], {i, 0, n}]

```

---

<div class="post-metadata">

**Author:** ![bsimpson141421356](https://avatars.discourse-cdn.com/v4/letter/b/ac91a4/32.png) [@bsimpson141421356](https://community.wolfram.com/u/bsimpson141421356)\
**Post date:** [March 24, 2014, 2:37am UTC](https://community.wolfram.com/t/loop-statement-inside-an-exponential/1789/2 "2014-03-24T02:37:04Z")

</div>

```auto
In[1]:= k = 1;
A = 5;n = 4;
Table[If[i==0, "1", StringReplace["Exp[-I*2*Pi*k*z]", "z"->ToString[InputForm[i/A]]]], {i, 0, n}]

Out[4]= {1, Exp[-I*2*Pi*k*1/5], Exp[-I*2*Pi*k*2/5], "Exp[-I*2*Pi*k*3/5], Exp[-I*2*Pi*k*4/5]}

```

Will that do? It is producing strings to try to match your format exactly.

If you then need to use this result for further calculations then ToExpression can convert it back.

---

<div class="post-metadata">

**Author:** ![sproubi1](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@sproubi1](https://community.wolfram.com/u/sproubi1)\
**Post date:** [March 24, 2014, 2:44am UTC](https://community.wolfram.com/t/loop-statement-inside-an-exponential/1789/3 "2014-03-24T02:44:33Z")

</div>

Thanks, Bill. Now I have to take the Output and apply to a Discrete Fourier Tranform.

---

<div class="post-metadata">

**Author:** ![bsimpson141421356](https://avatars.discourse-cdn.com/v4/letter/b/ac91a4/32.png) [@bsimpson141421356](https://community.wolfram.com/u/bsimpson141421356)\
**Post date:** [March 24, 2014, 3:05am UTC](https://community.wolfram.com/t/loop-statement-inside-an-exponential/1789/4 "2014-03-24T03:05:54Z")

</div>

If you are only using this for calculations and don’t care about the exact formatting then this might be simpler

```auto
In[4]:= k = 1;A = 5; n = 4;Table[Exp[-I*2*Pi*k*i/A], {i, 0, n}]

Out[6]= {1, E^(-((2 I \[Pi])/5)), E^(-((4 I \[Pi])/5)), E^((4 I \[Pi])/5), E^((2 I \[Pi])/5)}

```
