Finding a number when its remainder is given. I am trying to solve this problem


  
    W is a positive integer when divided by 5 gives remainder 1 and when divided by 7 gives remainder 5. Find W.
  


I am referring back to an earlier post I made. Now I am attempting to solve it that way.

We know that 
$$w\equiv1(mod~5)$$
$$w\equiv5(mod~7)$$

$w=7r+5$

$w=5r+5+2r$

Since $5r+5$ is divisible by 5

$w=5(r+1)+2r$ this shows the remainder is $2r$

Now $2r$ divided by 5 gives a remainder 1 , thus giving the equation

$2r = 5k + 1$ or $r=\frac{5k+1}{2}$

Putting r back in $w=7r+5$ we get 

$2w = 35k + 12$

So I guess $w= \frac{35+12}{2} = 23.5$

This is wrong and the answer is suppose to be 26. Any suggestions what I might be doing wrong ? or anything that I might be missing ?

Edit:
The problem was in calculation 

$w= \frac{35+17}{2} = 26$
There is an error: $\rm\:w=7r\!+\!5\,\Rightarrow\,2w = 7(2r)\!+\!\color{#C00}{10} = 7(5k\!+\!1)\!+\!\color{#C00}{10} = 35k\!+\!\color{#C00}{17},\:$ not $\rm\:35k\!+\!\color{#0A0}{12}.$
Since $\rm\:35k\!+\!17 = 2w\:$ is even, $\rm\:k\:$ is odd, $\rm\:k = 2j\!+\!1,\,$ so $\rm\:w = (35(2j\!+\!1)\!+\!17)/2 = 35j+26.$

Remark $\ $ It is easier to do the division by $2$ before the substitution. Namely, we have $\rm\:2r = 5k\!+\!1\:$ so $\rm\:k\:$ is odd, $\rm\:k = 2j\!+\!1,\:$ thus $\rm\:r = (5k\!+\!1)/2 = (5(2j\!+\!1)\!+\!1)/2 = 5j\!+\!3.\:$ Therefore $\rm\:w = 7r\!+\!5 = 7(5j\!+\!3)\!+\!5 = 35j\!+\!26.$ Notice how the numbers remain smaller this way.

I emphasize again, it's much more intuitive if you learn about modular arithmetic (congruences). For many examples see my posts on Easy CRT (easy version of the Chinese Remainder Theorem)
$w\equiv 1 \mod5 \Longrightarrow w=5a+1$, and
$w\equiv 5 \mod7 \Longrightarrow w=7b+5$  .

Multiply the first by 7 and the second by 5:
$7w=35a+7$ , and
$5w=35b+25$.

Subtract:
$2w = 35(a-b) - 18$.  

$\Longrightarrow 2w \equiv -18 \mod 35$,
$\Longrightarrow 2w \equiv 17 \mod 35$
$\Longrightarrow 2w \equiv 52 \mod 35$
$\Longrightarrow w \equiv 26 \mod 35$