I'm working with some sequences and could be useful to know how to find a pattern behind them:
I currently have two sequences:
$8,20,20,20,24,36,36,36,40,52,52,52,56...$
$12,16,20,40,40,40,40,40,44,48,52,72,72,72,72,72,76,80...$
I can see the repeating patterns, but how do I write down $a_n= ... $?
The first one goes $(+12,+0,+0,+4,...)$ and repeats itself each time.
The second goes $(+4,+4,+20,+0,+0,+0,+0,+4,...)$
I want to know how to create the two an based on $(+12,+0,+0,+4,...)$ for the first and $(+4,+4,+20,+0,+0,+0,+0,+4,...)$ for the second.
Using zero-based indexes, $$a_{4n}=8+16n,\\a_{4n+1}=20+16n,\\a_{4n+2}=20+16n,\\a_{4n+3}=20+16n$$ and similar for the second sequence.
If you want a one-liner,
$$a_n=20-2(n\bmod4-1)(n\bmod4-2)(n\bmod4-3)+4(n-n\bmod4).$$
The second takes a more complex polynomial in $n\bmod 8$ (Lagrangian interpolator).