Sometimes I will see a function being defined and then something like "... where $k$ $\in$ $[1 : n]$, I gathered that it is something along the lines of between 1 and n but why isn't this just written as $1$ $\le$ $k$ $\le$ $n$?
Thanks
Sometimes I will see a function being defined and then something like "... where $k$ $\in$ $[1 : n]$, I gathered that it is something along the lines of between 1 and n but why isn't this just written as $1$ $\le$ $k$ $\le$ $n$?
Thanks
The notation $k \in [1:n]$ means that $k$ belongs to the set of integers between $1$ and $n$, i.e. $k \in [1:n] \iff k \in \{1, 2, \cdots, n\}$ and therefore implies that $k$ is an integer. Writing $1 \leq k \leq n$ just means that $k$ is a real number between $1$ and $n$. It could be an integer, a rational, an irrational number. As long as it is greater than $1$ and smaller than $n$.
They are synonymous, though $[1,n]$ is the more common notation. I prefer $[1..n]$ myself.
Note that there is some ambiguity in notation, as it is unclear whether these are intervals of real numbers or intervals of integers. Usually this meaning can be determined from context.
$[1:n]$ is a set of numbers, and to say that $k \in [1:n]$ means $k$ belongs to the set with a certain property.
That property is that $1 \le k \le n$.
So one is a set and one is a property. But you can define a set as "all elements with a certain property", and you can define a property as "belongs to this set", so they're equivalent.