Finding a single equation without use of words, only functions and math, that solves outputs patterns within patterns If you were given a sequence that went something like
$$1,1,3,2,5,3,7,4,9,5....$$
You would notice that there are two patterns alternating, one being 1,3,5,7,9... and the other being 1,2,3,4,5...
How would you define this sequence with one single function, $k(n)$,without the use of words or extra functions such as "If n is even, apply the function $f(n)=\frac{n}{2}$ and if n is odd, apply the function $f(n) = n$"
Is there an elegant way to output such a sequence? I tried to do it and have my own way using a lot of terms but want to know if there is a much simpler solution
Furthermore, if your particular equation works for this equation, would it work for $p=3,4,5,6...$ patterns within a pattern. In addition, the patterns rotate uniformly meaning if there were 4 patterns, every 4 terms the same function is used to output a number based on the term number: An example of 4 patterns in a pattern that follow the following functions $f(n)=n,f(n)=n^2,f(n)=3n,f(n)=\lfloor{\sqrt{n}}\rfloor$, a certain function $k_p(n)$ where $p=4$ would output 
$$1,4,9,2,$$$$5,36,21,2$$$$9,100,33,3...$$
(The spacing is just for visual purposes and makes it easier to see how each pattern rotates every 4 terms)
Whatever solution that outputs such a pattern should also be able to change or be manipulated easily to accommodate more or less patterns with functions for each pattern varying in complexity
Update:
A common way that people are trying to use to solve the first example with only two simple patterns is through the use of the properties of $(-1)^n$ which outputs -1 or 1, an alternating sequence between two values, perfect for the first example. I hope that further answers to this question should somehow expand to the next part of it as I know there are more than enough equations that output the first pattern.
My Work:
I tried using modulus arithmetic to output the values I wanted that would sort of turn off or turn on certain functions depending on the term $n$. For the first example, I made the equation $k_2(n)= (mod(n,2))*n + (mod(n+1,2))*(\frac{n}{2})$
I think further work can be done in improving the modulus method as there is a common number between the mod sections of $k_2(n)$ and the number of patterns $p$ which is 2

$$f(n)=\frac{n}{2-n+2\lfloor\frac{n}2\rfloor}$$
Not very elegant, though.
