Finding a constant in a density function 
Suppose
  $$
f(x)= \begin{cases} 0, & \text{for }x<0, \\ \\ kx, & \text{for } 0\le x < 1, \\ \\0, & \text{for } x\ge1 \end{cases}
$$
  is the density of a random variable $X$. How do I find k?


The book says the solution is $2$.
I apologize if this is unsolvable, incoherent and/or missing information. This is from my maths schoolbook which is full of such mistakes. I copied the problem as it is.

I'm assuming that the $f$ you have written is a probability density fuction of a random variable $X$. A defining property is that $\int f(x) \; dx =1$ for all pdf's. In our case,
$$
\int f(x) \; dx = \int_0^1 kx \; dx = \frac{k}{2}
$$
and so $k$ must be equal to two.
