Creating a sine function with specific parameters Part1(Solved)
Is it possible to create a function that maps x to y as follows:
x 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...
y 0 1 2 3 4 5 4 3 2 1  0  1  2  3  4  5 ...
So far, this is what I have been able to come up with:
|5 sin ((1/10)pix)|
Which will give the following y's for x = 0 to 10:
 0.00000
 1.5451
 2.9389
 4.0451
 4.7553
 5.0000
 4.7553
 4.0451
 2.9389
 1.5451
 0.00000

This sequence will repeat every 10 steps, with the peak (5) at step 5. This is getting close to what I want so all that is left is to somehow adjust the function so that the required integers appear (1,2,3,4), but I don't know how.
Since the function is cycling through a series of numbers over and over, I figured that it might be possible to write the function in terms of a periodic function and not piece by piece.
Please comment. 
Part2
How would I go about writing a function that produce the following plot:(x is an integer >=0 , the pattern repeats after x = 8)

Can this plot be expressed using a single formula or must it be defined piecewise?
  Thank you.

You ask for a function. A function is a mapping from one set to
another set, but you neglect to specify which sets. Your list of
$x$-values consists of small nonnegative integers together with
an ellipsis. From this, one might surmise that your intended
domain is $\mathbb{N}_0$, the set of nonnegative integers. Likewise
you do not specify a codomain, but let's say for argument's sake
that it is $\mathbb{N}_0$, the same as the domain.
Of course there are uncountably many functions from $\mathbb{N}_0$
to $\mathbb{N}_0$ containing your specified values. But you mention
it has to be a "sine" function. The term sine refers to a particular
function on the real numbers, taking all values between $-1$ and $1$
and having period $2\pi$. Your function cannot have all of these
properties. Perhaps by a "sine" function you mean a periodic function?
If so here is one defined on $\mathbb{N}_0$ which extends your table
of values:
$$f(n)=\begin{cases}
0&\text{if }n\equiv 0 \pmod {10},\\\\
1&\text{if }n\equiv\pm1 \pmod {10},\\\\
2&\text{if }n\equiv\pm2 \pmod {10},\\\\
3&\text{if }n\equiv\pm3 \pmod {10},\\\\
4&\text{if }n\equiv\pm4 \pmod {10},\\\\
5&\text{if }n\equiv 5 \pmod {10}.
\end{cases}$$
Of course, unlike the actual sine function, this never takes negative
values.
Perhaps as in Hans's comment, you want a function on the reals
restricting to your table of values. Here is a piecewise linear
example as Hans suggests:
$$g(x)=
\begin{cases}
10\{x/10\}&\textrm{if }\{x/10\} < 1/2,\\
10-10\{x/10\}&\textrm{if }\{x/10\}\ge 1/2
\end{cases}$$
where $\{t\}$ denotes the fractional part of a real number $t$.
