Summation with Do and For functions

How exactly do I attack these problems?? the best I can come up with is …
For[Print[8/(10^x)], {x, 2, 16, 2}]
Thanks All!

  1. Suppose you started with a variable, set that equal to zero, inside your For you added something to the variable that was computed from your x value and after the For is done perhaps do something useful with the variable?

  2. and 3) A For (sort of) automatically does some things for you. A Do and a While do a little less and leave those things to do for yourself. Can you again suppose you start with a variable, look at the help page for Do and While and try to think how to sort of make the same things happen with a little code you write yourself? You might also look at the help page for Break and see if that might or might not be useful.

Did they perhaps mention anything that might seem similar to this in class?

Hopefully those hints will be enough to get you started.

I hope it works out

In Mma you dislike to use Do[], For[] or While[] for such an excercise because there is Table[]:

In[31]:= N[8 (Plus @@ Table[10^(-2 o), {o, 0, 7}])/100, 32]
Out[31]= 0.080808080808080800000000000000000

If you are forced to use For[], you write

In[33]:= Block[{x = 0}, For[o = 1, o < 9, o++, x += 8 10^(-2 o)]; N[x, 32]]
Out[33]= 0.080808080808080800000000000000000

If you are forced to use Do[], you write

In[37]:= Block[{x = 0}, Do[x += 8 10^(-2 o), {o, 1, 8}]; N[x, 32]]
Out[37]= 0.080808080808080800000000000000000

If you are forced to use While[¨], you write

In[41]:= N[Block[{x = 0, o = 1}, While[o < 9, x += 8 10^(-2 o); o++]; x], 32]
Out[41]= 0.080808080808080800000000000000000

If you are forced to use the Do[] with a condition on the iteration variable you compute that condition

In[49]:= N[Block[{x = 0}, Do[x += 8 10^(-2 o), {o, 1, Ceiling[Log[10, 8/0.0001]]}]; x], 32]
Out[49]= 0.080808080800000000000000000000000

Regards
Udo.

You appear to be testing to see if the n-term approximation to the infinite sum is sufficient.

SumConvergence says that the sum converges unconditionally:

In[1]:= SumConvergence[8/10^(2 n), n]

Out[1]= True

and Sum gives the value to which the infinite series converges:

In[2]:= Sum[8/10^(2 n), {n, Infinity}]

Out[2]= 8/99

Best regards,
David

You may also consider the numeric approximation using N, Total and Table:

In[1]:= f[max_]:=N[Total[Table[8/(10^n),{n,2,max,2}]],max]

In[2]:= f[1000]

Out[2]= 0.08080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080