[Math] Finding the general formula of a sequence alternating between even and odd

arithmeticsequences-and-series

So I know how to find the general formula of a simple sequence and sequences involving alternating signs but how would you devise a general formula for sequqences alternating between even and odd numbers with different operations occuring to even and odd numbers For example we have the sequence

                    13, 17, 23, 27, 33, 37...

The sequence starts at 13 and as you can see if the number of the term is odd then we add 4 and if it's even we add 6. I have also devised two separate formula for even and odd numbers. For example if we have to find the 2oth term we use the formula (10n + 7) as 20 is even. If we have to find 21st term we plug it into (10n + 3) as its odd. What I want is a way to devise one general formula for the whole sequence. Is there even a way to do this? Any help would be appreciated. Thanks.

Best Answer

Apart the possibilities already suggested (use of $mod$ and use of $(-1)^n$, you can also use the floor function $$ f(n) = 6n+7-2\left\lfloor\frac{n}{2}\right\rfloor $$

Related Question