15
$\begingroup$

The sequence is $f = 0, 1, 0, 1, \ldots$

I want to find a general formula for the $n$th element. The sequence starts at $n = 0$ (the $0$ here is not the first element $0$ but rather denotes the $0$th position).

One easy and obvious solution is: $n$th $f = n \bmod 2$. This works because even positions have $0$ and odd positions have $1$.

However, this question is part of a homework and modulus has not been discussed (or part of the syllabus or even a prerequisite). And so I am hesitant to use it.

Is there another way to solve this problem using only basic arithmetic operations (one that a beginning high schooler knows of)?

$\endgroup$
2
  • 2
    $\begingroup$ Do beginning high-schoolers know about Wolfram Alpha? Go to that website and type Boole[OddQ[Range[0, 99]]] in the box. $\endgroup$ Commented Sep 25, 2018 at 21:05
  • $\begingroup$ Not sure if you accept recurrence formulas, but that then you would have simple one $a_{n+1}=1-a_{n}$ with $a_0=0$. $\endgroup$
    – Sil
    Commented Oct 12, 2018 at 8:08

8 Answers 8

18
$\begingroup$

$a_n=(1/2)(1+(-1)^{n+1})$, $n=0,1,2,.....$

$\endgroup$
11
+100
$\begingroup$

The expression for the $n$th element of that sequence $f$ should take account of the products of $(-1)$.

As every number $n$ that appears in your sequence is just $$n = \frac{1}{2} + k,$$ where $$k = \pm\frac{1}{2},$$ then the general expression for the $n$th term $f_n$ would be the sum of the term $k$ to the $n$th: $$f_n = \frac{1}{2} + (-1)^n \left(\frac{1}{2}\right).$$

Considering that your sequence starts with the value $0$ in the first term. $(-1)^1 = -1, (-1)^2 = 1$, and so on.

$\endgroup$
7
$\begingroup$

Consider whether you can adjust the sequences from either of:

  • $(-1)^n$
  • $\cos(\pi n)$

to get what you are looking for, for example by adding a constant and/or multiplying by a constant

$\endgroup$
6
$\begingroup$

Have you learned about exponents yet, including the special cases $x^0$ and $x^1$? Here's a slightly more complicated definition using those exponents: $f(0) = 0$, $f(1) = 1$ (that's what software developers would call "initialization") then $$f(n) = f(n - 2)^{f(n - 1)}$$ for $n > 1$.

You could also do $f(n) = f(n - 2)$, though you could come across a smart-aleck with that one.

$\endgroup$
6
$\begingroup$

First, some notes:

  • If you were to explain the functions you use (same goes for modulus), maybe your homework would get accepted anyway.
  • $\lceil{x}\rceil$ denotes the ceiling function which takes as input the real number $x$ and gives as output the least integer greater than or equal to $x$, i.e. $\lceil{5.3}\rceil=6$.
  • $\lfloor{x}\rfloor$ denotes the floor function which takes as input the real number $x$ and gives as output the greatest integer less than or equal to $x$, i.e. $\lfloor{5.3}\rfloor=5$.
  • When $x$ is an integer, then $\lceil{x}\rceil=\lfloor{x}\rfloor=x$.

With this mind:

Your sequence $$\{f_n\}=0,1,0,1,0,1,\dots$$ can be generated by the function $$f_n=\left\lceil\frac{n}{2}\right\rceil-\left\lfloor\frac{n}{2}\right\rfloor,\;\ n\in\mathbb{Z}^{\ge0}$$ For each even positive integer $n$ (including $0$), the ceiling and floor function evaluate to equal values, canceling each other out; $f_n=0$.

For each odd positive integer $n$, the ceiling and floor function evaluate to values differing by $1$; $f_n=1$.

$\endgroup$
5
$\begingroup$

Is the sequence just an eternal alternation of 0 and 1? Then all you need to do is put in a couple dozen alternations in the OEIS, find https://oeis.org/A000035, then just sit back and read until you find a formula you like.

Least significant bit of $n$, lsb(n).

This works even if $n$ is negative, but it gets a little bit into computer science.

Also decimal expansion of $\frac{1}{99}$.

Yeah... if you ignore the integer 0 in 0.01010101010101010101010101010101...

Also the binary expansion of $\frac{1}{3}$.

Though I'm not sure this applies under the IEEE 754 floating point format specification.

There's a whole bunch more to look at. I personally like the recurrence relation $a(n) = 1 - a(n - 1)$, which is of course initialized with $a(0) = 0$.

$\endgroup$
1
  • 3
    $\begingroup$ Thanks for the amazing resource. $\endgroup$ Commented Sep 25, 2018 at 15:50
5
$\begingroup$

You could compact the alternating sign formula with $$f(n) = \sin \left( \frac{n \pi}{2} \right)^2$$

Applying $$(\sin(x))^2= \left( \frac{1}{2} \right)(1 - \cos(2x)) $$

So you get $0, 1, 0, 1, 0, 1, \ldots$

$\endgroup$
1
$\begingroup$

We can apply the sign function:

$$a_n=\mathrm{sgn}(1-(-1)^n)\qquad\qquad n=0,1,2,\ldots$$

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .