3
$\begingroup$

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.

$\endgroup$
2
  • 1
    $\begingroup$ Check FindGeneratingFunction. It is generating equation. $\endgroup$ Commented Oct 16, 2013 at 18:58
  • 2
    $\begingroup$ Related: oeis.org/A129756 $\endgroup$
    – Michael E2
    Commented Oct 18, 2013 at 1:04

3 Answers 3

6
$\begingroup$

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}
$\endgroup$
5
$\begingroup$

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}
$\endgroup$
2
$\begingroup$

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}
$\endgroup$

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.