Question: How do you find the number of floors,in a tetraphobic numbering system like 1,2,3,5,6,7,..,12,13,15..,39,50.

I am trying to find the pattern and the mathematical algorithm to solve for floor numbered n.

for eg 
n = 3 : ans = 3
n = 8 : ans = 7
n = 22 : ans = 20

Note: This is not a HW problem , I read about it and tried to solve it as fun, I am stuck so I am asking here

Answer: 
Let $\pi$ be a uniformizer of $A$. Suppose $\phi(X\_{i}) = u/\pi^{m}$ for some $u \in A^{\times}$ and $m \ge 0$. Then $\pi^{m}X\_{i}-u$ is a unit of $A[[X\_{1},\dotsc,X\_{n}]]$ that gets mapped to $0$ in $K$, contradiction.
This is true. More generally, for any finite extension $K^\prime$ of $K$, any $A$-algebra map $A[[X\_1,\ldots,X\_n]]\to K^\prime$ has image in the valuation ring $A^\prime$ of $K^\prime$, and the induced map $A[[X\_1,\ldots,X\_n]]\to A^\prime$ is local (i.e., the $X\_i$ are sent to elements of the maximal ideal of $A^\prime$). 

To prove this, first note that $A$-algebra maps $A[[X\_1,\ldots,X\_n]]\to K^\prime$ are in natural bijection with $A^\prime$-algebra maps 

$$A^\prime[[X\_1,\ldots,X\_n]]=A^\prime\otimes\_AA[[X\_1,\ldots,X\_n]]\to K^\prime,$$

where the first identification is valid because $A^\prime$ is a finite free $A$-module (the analogous identity with $K^\prime$ in place of $A^\prime$ is not valid for $n\geq 1$). So we may assume $K=K^\prime$ (hence also $A=A^\prime$), and consider an $A$-algebra map $A[[X\_1,\ldots,X\_n]]\to K$. If we can show that this map necessarily sends each $X\_i$ to an element in the maximal ideal $\mathfrak{m}$ of $A$, then completeness of $A$ can be used to deduce that the image of the map is contained in $A$, so it is enough to verify the former claim. Moreover, this claim holds if and only if the analogous claim holds for the $n$ compositions 

$$A[[X\_i]]\hookrightarrow A[[X\_1,\ldots,X\_n]]\to K,$$

(here $1\leq i\leq n$). Thus we may also assume that $n=1$, in which case we can apply the structure theory of the $2$-dimensional regular local ring $A[[X\_1]]$ (especially the Weierstrass Preparation Theorem). The kernel of $A[[X\_1]]\to K$ must be nonzero because $K\otimes\_AA[[X\_1]]$ is an infinite-dimensional $K$-vector space. Therefore the kernel contains a height one prime ideal, and any such ideal is generated by a "distinguished polynomial" $f\in A[X\_1]$ (this is a monic polynomial of positive degree whose lower-degree coefficients lie in $\mathfrak{m}$). The division algorithm for $A[[X\_1]]$ shows that for such an $f$, the natural map $A[X\_1]/(f)\hookrightarrow A[[X\_1]]/(f)$ is an isomorphism, so the map in question can be thought of as an $A$-algebra map $A[X\_1]/(f)\to K$. Thus the image $a\_1$ of $X\_1$ in $K$ is a root of $f$. Because $f$ is monic and $A$ is integrally closed, we must have $a\_1\in A$, and since the lower-degree coefficients of $f$ are in $\mathfrak{m}$, we may conclude that $a\_1$ is as well.