0
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ How about $a_n=10\lceil{n/2}\rceil+7-4(n\bmod2)$? $\endgroup$ – barak manos Mar 29 '16 at 9:26
0
$\begingroup$

Here is an answer using simple arithmetics: $$5\Big(n+\frac{3-(-1)^n}2\Big)+2\cdot(-1)^n$$

$\endgroup$
  • $\begingroup$ could you explain how this works $\endgroup$ – abdullahaquarius Mar 29 '16 at 9:51
  • $\begingroup$ Yes you are right but could you please explain it a bit $\endgroup$ – abdullahaquarius Mar 29 '16 at 9:54
  • $\begingroup$ @abdullahaquarius Do you know the exponentiation? $a^n = \underbrace{a\cdot a\cdot\ldots\cdot a}_{n\text{ times}}$. In this case, $(-1)(-1)\ldots(-1)$ is either $1$ or $-1$ depending on $n$. $\endgroup$ – user326572 Mar 29 '16 at 9:56
  • $\begingroup$ Okay I got it. thanks a lot. I had gotten to the part of 5(n+1+(-1)^n)+2 * (-1)^n $\endgroup$ – abdullahaquarius Mar 29 '16 at 10:05
  • $\begingroup$ But that didn't work with one, but yours does so thanks a lot. $\endgroup$ – abdullahaquarius Mar 29 '16 at 10:06
0
$\begingroup$

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 $$

$\endgroup$
  • $\begingroup$ could you explain how this works $\endgroup$ – abdullahaquarius Mar 29 '16 at 9:40
  • $\begingroup$ @abdullahaquarius I assume you know the floor function. $\lfloor n/2\rfloor$ is equal to $n/2$ if $n$ is even and is equal to $(n-1)/2$ if $n$ is odd. Hence, twice that it is equal to $n$ if $n$ is even and $n-1$ if $n$ is odd. So in practice the formula is $6n+7-n=5n+7$ when $n$ is even, giving the terms $\cdot,17,\cdot,27,\cdots$ and it is equal to $6n+7-(n-1)=5n+6$ when $n$ is odd, giving the terms $13,\cdot,23,\cdot,33,\cdots$. $\endgroup$ – Giovanni Resta Mar 29 '16 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.