Displaying a telescoping series [duplicate]

I'd like to show my students what happens with the telescoping series $\sum_{n=1}^\infty\left[\frac{1}{n}-\frac{1}{n+1}\right]$. For example, I would like to display the partial sum: $$s_5=\left[1-\frac12\right]+\left[\frac12-\frac13\right]+\left[\frac13-\frac14\right]+\left[\frac14-\frac15\right]+\left[\frac15-\frac16\right]$$ I've not used HoldForm before, but I tried:

Table[HoldForm[1/n - 1/(n + 1)], {n, 1, 5}]


But that didn't work. Any suggestions?

• Far from perfect, but a bit better : show[n_?NumericQ] := Defer[1/n - 1/(n + 1)]; Table[show[n], {n, 5}] outputs {1 1/1 - 1/(1 + 1), 1/2 - 1/(2 + 1), 1/3 - 1/(3 + 1), 1/4 - 1/(4 + 1), 1/5 - 1/(5 + 1)}. Feb 21, 2017 at 16:58
• Or, better, this show[n_?NumericQ] := Block[{m = n + 1}, Inactivate[1/n - 1/m, Plus]]: Feb 21, 2017 at 18:30
• Do you think it is a valid duplicate: Getting terms and only evaluate specific parts?
– Kuba
Feb 21, 2017 at 20:09
• Related: 110532 Feb 21, 2017 at 22:12
• I'd like to thank all my colleagues for tremendous help. There is a lot to learn here and some great examples to share with my students. Feb 22, 2017 at 7:28

In the following way you can get the printed result you are asking for:

lst=Table[1/n, {n, 1,6}];


Here is another, simpler, solution:

HoldForm[1 - 1/2] + Sum[With[{n = n, m = n + 1}, HoldForm[1/n - 1/m]], {n, 2, 5}]


When we would have started the summation with n=1 instead of n=2, the very first number 1/1 would have turned up as 1*1/1, which is not what we want. Compare this question. An acceptable output is given by:

Sum[With[{n=n, m=n+1}, HoldForm[Divide[1,n]-Divide[1,m]]], {n,1,5}]

• @egwene sedai. Many thanks for including the output! Feb 21, 2017 at 18:57
• I think you need to make two edits, as in: Sum[With[{n=n,m=n+1},HoldForm[Divide[1,n]-Divide[1,m]]],{n,1,5}] and HoldForm[1 - 1/2] + Sum[With[{n = n,m = n + 1}, HoldForm[1/n - 1/m]], {n, 2, 5}]. Awesome answer. Mar 15, 2017 at 4:45
• @David. You are right that I do not need the three arguments form of With. So I edited my answer accordingly.. Mar 15, 2017 at 7:59

Here's a start, first by inactivating Plus everywhere, then reactivating it in the denominators:

ReplaceAll[
Block[{Plus = Inactive[Plus]}, Sum[1/i - 1/(i + 1), {i, 1, 5}]],
-Inactive[Plus][v__]^(-1) :> -Plus[v]^(-1)
]


• Simpler is Inactivate[Sum[1/i - 1/(i+1), {i, 5}], Plus] although it isn't equivalent because Sum produces an active Plus. Feb 21, 2017 at 17:13
• @CarlWoll It is simpler to write, but the result gets reordered when I use Inactivate. I do not fully understand why, but I wanted to retain the ordering shown in OP. Feb 21, 2017 at 17:16
d = Table[If[n == 1, 1, 1/ToString[n]] - 1/ToString[n + 1], {n, 1, 5}];
s = "[" <> ToString[d[[1]], StandardForm] <> "]";

For[ii = 2, ii <= Length[d], ii++,
s = s <> "+[" <> ToString[d[[ii]], StandardForm] <> "]";
]