1

For a certain sequence of numbers, the sum of the first $n$ numbers in the sequence is given by $n^3+4n$ for all positive integers $n$. What is the fifteenth number in the sequence?

How do you solve this problem the most efficient way?

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
  • Are you sure you're on an appropriate site? This one is for Mathematica programming. – Artes Oct 09 '15 at 04:10
  • Step 1: Ask on the right fora. You're after math.stackexchange... – ciao Oct 09 '15 at 04:10
  • 4
    Ask how to solve it on a site full of people who like solving problems? :-) – Brett Champion Oct 09 '15 at 04:22
  • People coming in from the hot questions list, please note the answers are fancy looking ways to do subtraction. I seriously don't understand the top answer (as in, why the duck that is the top answer), top answer should be s(15)-s(14) – Alec Teal Oct 09 '15 at 09:35
  • @AlecTeal The reason why my fellow Mathematica(TM) programmers and scientists found my answer interesting is because it's a literal translation to Mathematica(TM) of the problem exactly as posed by the OP (Solve fizz when buzz happens), without thinking in the math involved, and showing that Mathematica (TM) is able to solve it without human "intervention" – Dr. belisarius Oct 09 '15 at 13:17

4 Answers4

9
Solve[Table[Sum[f[i], {i, 1, n}] == n^3 + 4 n, {n, 15}], Array[f, 15]]

(*
 {{f[1] -> 5, f[2] -> 11, f[3] -> 23, f[4] -> 41, f[5] -> 65, 
   f[6] -> 95, f[7] -> 131, f[8] -> 173, f[9] -> 221, f[10] -> 275, 
   f[11] -> 335, f[12] -> 401, f[13] -> 473, f[14] -> 551, 
   f[15] -> 635}}
 *)
Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453
7
(FindSequenceFunction@ Differences[Prepend[n^3 + 4 n /. n -> Range@10, 0]])@15

(* 635 *)
ciao
  • 25,774
  • 2
  • 58
  • 139
6

Might as well...

DifferenceDelta[n^3 + 4 n, n] /. n -> 15 - 1
J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
5

Let $S_n=\sum^n_{j=1}a_n$. So $a_n=S_n-S_{n-1}$.

5 - 3 n + 3 n^2 /. n -> 15

yields 635. (Mathematica can obviously do this).

ubpdqn
  • 60,617
  • 3
  • 59
  • 148
  • I saw the beginning of your answer and thought you were going to give an answer suitable for math.se. – Brett Champion Oct 09 '15 at 06:41
  • @BrettChampion...I can delete if you feel this is not in the spirit of the site. I just thought given the precise expression of the question, this was the simplest approach... – ubpdqn Oct 09 '15 at 06:44
  • This is more or less what DifferenceDelta[] does, made explicit. – J. M.'s missing motivation Oct 09 '15 at 08:15
  • @J. M. yes...I am sorry if it seemed like being a wise-guy...I just thought simplicity was warranted...I did upvote your answer as I was not aware of DifferenceDelta. I am happy to delete and acknowledge all the answers get to the same result. :) – ubpdqn Oct 09 '15 at 08:19
  • No, I didn't take it like that! I was merely adding an explanatory note; at least, OP will need to think a little bit more for your solution. :) – J. M.'s missing motivation Oct 09 '15 at 08:21