Floors are numbered by skipping fours, Find actual number of floors. 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
 A: I'll do an example.  You can elaborate it into an algorithm. Which floor has number $7619?$ 
The way to approach this is to count how many floors we skip.  Call $10$ consecutive two-digit numbers where the first ends in $1$ and the last in $0$ a "decade."  Similarly define a "century" and a "millennium."  In a decade that starts with $4$ we skip $10$ numbers, and in a decade that doesn't start with $4$ we skip $1$ number, so in a century that doesn't start with $4$ we skip $19$ numbers and in a millennium that doesn't start with $4$ we skip $100+9\cdot19=271$ numbers.
Now back to $7619.$  There are $7$ millennia up to $7000$.  In one of them we skip $1000$ number and in $6$ of them we skip $271$ giving $2626.$  Now we have to figure out how many are skipped from $7001$ to $7619.$  This is clearly the same number that are skip from $1$ to $619$.  There are $6$ centuries up to $600$ and in one of them we skip $100$ numbers, and in the other $5$ we skip $19$, making $195,$ and a total of $2821$ so far.  Now we have to count how many number are skipped from $601$ to $619$ which is the same as the number skipped from $1$ to $19$.  We can apply the same idea and get $2,$ so that $2823$ numbers are skipped in all.
The final answer is $7619-2823=4796$
A: I found a better answer. The floor number are in basically in base-9 as it never uses one number (0-3 and 5-9) where as the number of floors is in base-10 (0-9) because it uses all decimal digits.
We convert the floor number to proper base-9 number decrementing all digits that are greater than 4 by 1. Once you have a base-9 number , convert it to base-10.
Eg. Floor-number : 56
       Base -9.          :  45
       Base-10 (Ans):  41
