Integral with floor function resulting in EulerGamma

This is almost the required one.

Sum[Integrate[1/t - n/t^2, {t, n, n + 1}], {n, 1, Infinity}]
(*1 - EulerGamma*)

The difficulty consists in

FullSimplify[1/t - Floor[t]/t^2, Assumptions -> n > 0 && n \[Element] Integers && t >=n && t < n + 1]
(*(t - Floor[t])/t^2*)

One sees Mathematica is not able to simplify Floor[t] to n under the assumptions.


In cases you have problems to determine the integrand depending on n, you can calculate integrals for some n and find formula for the integral with FindSequenceFunction .

Calculate the difference for n+1 and n and sum up the found formula. Since FindSequenceFunction does not recognize Log, do it in two steps.

tab = Flatten@
  Table[{Integrate[(t - Floor[t])/t^2, {t, 1, n + 1}] - 
  Integrate[(t - Floor[t])/t^2, {t, 1, n}] // Expand}, {n, 1, 8}]

fs1 = FindSequenceFunction[tab /. Log[_] -> 0, n];
fs2 = FindSequenceFunction[Cases[tab, Log[aa_] -> aa, 2], n];

int1 = fs1 + Log[fs2]

(*   1/(-1 - n) + Log[(1 + n)/n]   *)

Sum[int1, {n, 1, ∞}]

(*   1 - EulerGamma   *)

An other example:

tabx = Flatten@
  Table[{Integrate[(Floor[t] - t)/Ceiling[t]^2, {t, 1, n + 1}] - 
  Integrate[(Floor[t] - t)/Ceiling[t]^2, {t, 1, n}] // 
 Expand}, {n, 1, 8}]

(*   {-(1/8), -(1/18), -(1/32), -(1/50), -(1/72), -(1/98), 
      -(1/128), -(1/162)}   *)

fs1 = FindSequenceFunction[tabx, n]

(*   -(1/(2 (1 + n)^2))   *)

Sum[fs1, {n, 1, ∞}]

(*   1/2 (1 - π^2/6)   *)