Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm developing a questions game. My goal is that the score for each correct answer will increase as the user answers more questions. Initially there are 15 points for each correct answer. Every 4 questions adds 2 points to the previous value. In terms of numerical series would be something like:

15 15 15 15 17 17 17 17 19 19 19 19 21 21 21 21.

I trying to find the formula for this numerical serie but I have not had success. If anyone sees in this numerical series a "challenge" and wants to help me find the formula I will be very grateful.

share|improve this question
1  
Check FindGeneratingFunction. It is generating equation. –  Rorschach Oct 16 '13 at 18:58
2  
Related: oeis.org/A129756 –  Michael E2 Oct 18 '13 at 1:04
add comment

3 Answers

If I understand correctly:

f[n_] := 13 + Ceiling[n, 4]/2;

f[Range[20]]
{15, 15, 15, 15, 17, 17, 17, 17, 19, 19, 19, 19, 21, 21, 21, 21, 23, 23, 23, 23}

More general approach:

sample = {15, 15, 15, 15, 17, 17, 17, 17, 19, 19, 19, 19, 21, 21, 21, 21};
linrec = FindLinearRecurrence[sample]
 {1, 0, 0, 1, -1}
f2[n_] := LinearRecurrence[linrec, sample[[1 ;; Length[linrec]]], n];
f2[20]
{15, 15, 15, 15, 17, 17, 17, 17, 19, 19, 19, 19, 21, 21, 21, 21, 23, 23, 23, 23}
share|improve this answer
add comment

A nice use for the outer product:

Flatten@Outer[Times, Range[15, 23, 2], {1, 1, 1, 1}]

{15, 15, 15, 15, 17, 17, 17, 17, 19, 19, 19, 19, 21, 21, 21, 21, 23, 23, 23, 23}
share|improve this answer
add comment

Use FindGeneratingFunction and SeriesCoefficient:

FindGeneratingFunction[
  {15, 15, 15, 15, 17, 17, 17, 17, 19, 19, 19, 19, 21, 21, 21, 21, 23, 23, 23, 23}, x]
(15 - 13*x^4)/((-1 + x)^2*(1 + x + x^2 + x^3))

The formula:

FullSimplify[SeriesCoefficient[%, {x, 0, n}], Element[n, Integers] && n >= 0]
(1/4)*(57 + (-1)^n + 2*n + 2*Cos[(n*Pi)/2] + 2*Sin[(n*Pi)/2])

Verification:

Table[%, {n, 0, 30}]
{15, 15, 15, 15, 17, 17, 17, 17, 19, 19, 19, 19, 21, 21, 21, 21, 
 23, 23, 23, 23, 25, 25, 25, 25, 27, 27, 27, 27, 29, 29, 29}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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