# What is the formula for this numerical series?

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.

-
Check FindGeneratingFunction. It is generating equation. –  Rorschach Oct 16 '13 at 18:58
Related: oeis.org/A129756 –  Michael E2 Oct 18 '13 at 1:04

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}

-

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}

-

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}

-