Finding the Floor Function Explicit Formula for a Sequence

321 Views Asked by At

I have found come across two sequences that I know probably both have an explicit formula expressed in terms of the floor function, but I cannot quite figure it out.

$0,1,1,2,4,4,5,5,6,8,8,9,9,10,12,12$

$0,0,1,1,0,4,4,5,5,4,8,8,9,9,8,12$

(Note that the starting $0$ in both sequences is the $0$th term of both sequences.)

There is definitely a consistent pattern, but tricky to precisely describe. I have tried many possible formulas, graphed the sequences, and even referred to the OEIS, all to no avail. Any help would be appreciated!

2

There are 2 best solutions below

0
On

Notice that the first difference sequence of both sequences have period $5$. Equivalently, there is a constant difference after every $5$ terms which is $4$ for both sequences. Another way to state this is that $\, a_(n+5) = a(n) + 4 \,$ for all $n$ for both sequences. Thus, $\, a(n) = 4 \lfloor n / 5\rfloor + a(n \pmod{5}) \,$ for both sequences. Options vary about how to deal with the $\, a(n \pmod{5}) \,$ expression in the formula. It is purely periodic so you could use a sum of sines and cosines. You could use something like $\, (0,1,1,2,4)[n \pmod{5}] \,$ with the understanding that the finite list is indexed from $0$ to $4$.

If $\, a(n) \,$ and $\, b(n) \,$ are the two sequences, notice that $\, a(n) + b(n) = 8 \lfloor n / 5\rfloor + (n \pmod{5}). \,$

0
On

For the first series (ignoring 0 element):

$$a_n=4\left \lfloor{\frac{n-1}{5}}\right \rfloor+1+\left \lfloor{\frac{i}3}\right \rfloor+2\left \lfloor{\frac{i}4}\right \rfloor$$

...where:

$$i=n-5\left \lfloor{\frac{n-1}5}\right \rfloor$$

You can create one monster expression if you like it so. Proof:

In[24]:= a[n_] := Module[{i, s},
   s = 4 Floor[(n - 1)/ 5] + 1;
   i = n - Floor[(n - 1)/5]*5;
   s += Floor[i/3];
   s += 2 Floor[i/4]
   ];
Table[a[n], {n, 1, 30}]

Out[25]= {1, 1, 2, 4, 4, 5, 5, 6, 8, 8, 9, 9, 10, 12, 12, 13, 13, 14, \
16, 16, 17, 17, 18, 20, 20, 21, 21, 22, 24, 24}

The second sequence (ignoring 0 elemenet):

$$a_n=4\left \lfloor{\frac{n-1}{5}}\right \rfloor+\left \lfloor{\frac{i}2}\right \rfloor-2\left \lfloor{\frac{i}4}\right \rfloor+4\left \lfloor{\frac{i}5}\right \rfloor$$

...where:

$$i=n-5\left \lfloor{\frac{n-1}5}\right \rfloor$$

Proof:

In[26]:= a[n_] := Module[{i, s},
   s = 4 Floor[(n - 1)/ 5];
   i = n - Floor[(n - 1)/5]*5;
   s += Floor[i/2];
   s -= 2 Floor[i/4];
   s += 4 Floor[i/5]
   ];
Table[a[n], {n, 1, 30}]

Out[27]= {0, 1, 1, 0, 4, 4, 5, 5, 4, 8, 8, 9, 9, 8, 12, 12, 13, 13, \
12, 16, 16, 17, 17, 16, 20, 20, 21, 21, 20, 24}

Done.