1
$\begingroup$

For example, the sequence of triangular numbers can be expressed as $1/2 [n (n + 1)]$ with $n=1,2,3,4,...$ but is it possible to create a summation of everything remaining $(2,4,5,7,8,9,11,12,13,14,...)$? The problem I seem to have is the increasing amount of integers between each following triangular number.

$\endgroup$
0

1 Answer 1

2
$\begingroup$
ClearAll[f]
f[n_Integer] := Array[# (# + 1)/2 &, n, 1, Complement[Range[n (n + 1)/2], {##}] &]

f[5]

{2, 4, 5, 7, 8, 9, 11, 12, 13, 14}

Total @ f @ 5

85

You can get a closed form expression for the desired sum noting that (1) the sum of the first m triangular numbers is

Sum[n (n + 1)/2, {n, 1, m}]

1/6 m (1 + m) (2 + m)

and (2) the sum of integers up to m(m+1)/2 is

m (m + 1)/2 (1 + m (m + 1)/2)/2

Taking the difference and Simplifying:

m (m + 1)/2 (1 + m (m + 1)/2)/2 - Sum[ n (n + 1)/2, {n, 1, m}] // FullSimplify

we get

1/24 (-1 + m) m (1 + m) (2 + 3 m)

We can get the same result by generating a list of sums using f and using FindSequenceFunction on the list:

t[m_] := FindSequenceFunction[Total[f @ #] & /@ Range[100]][m]
t[m]

1/24 (-1 + m) (2 m + 5 m^2 + 3 m^3)

 t[5]

85

$\endgroup$
2
  • $\begingroup$ Truly excellent answer. $\endgroup$ Aug 1, 2018 at 22:43
  • $\begingroup$ Thank you @KennyColnago. $\endgroup$
    – kglr
    Aug 1, 2018 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.