Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	table := []int{0, 1, 2, 3, 5, 7, 8, 9}
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		out := make([]int, 10)
		now := 0
		for n > 0 {
			out[now] = table[n%8]
			now++
			n /= 8
		}
		tmp := make([]string, 0)
		for i := now - 1; i >= 0; i-- {
			tmp = append(tmp, strconv.Itoa(out[i]))
		}
		fmt.Println(strings.Join(tmp, ""))
	}
}

Python: def testcase_ends():
    n = int(input())
    if n == 0:
        return 1

    n = oct(n)[2:]
    n = n.replace('7', '9')
    n = n.replace('6', '8')
    n = n.replace('5', '7')
    n = n.replace('4', '5')
    print(n)
    return 0

def main():
    while not testcase_ends():
        pass

if __name__ == '__main__':
    main()

Python: def x(i):
    if i==0:
        return 0
    if i==1:
        return 1
    if i==2:
        return 2
    if i==3:
        return 3
    if i==4:
        return 5
    if i==5:
        return 7
    if i==6:
        return 8
    if i==7:
        return 9

while True:
    n = int(input())
    if n==0:
        break
    n = oct(n)
    n = list(n)
    del(n[0:2])
    for i in range(len(n)):
        print(x(int(n[i])),end='')
    print()

Python: while 1:
    n=int(input())
    if n==0:break
    n=str(oct(n)[2:])
    n=n.translate(str.maketrans('4567','5789'))
    print(n)

Python: while 4:
    n=int(input())
    if n==0:break
    print(oct(n)[2:].translate(str.maketrans("4567","5789")))

Python: import sys
  
#0123456789
#01234567
#01235789

def convert(dec):
    s = ""
    d = dec
    while True:
        div = d//8
        rem = d % 8
        d = div
        if rem == 4:
            rem = 5
        elif rem == 5:
            rem = 7
        elif rem == 6:
            rem = 8
        elif rem == 7:
            rem = 9

        s = str(rem)+ s
        if div <= 0:
            break
    return s

for s in sys.stdin:
    if int(s) == 0:
        break
    print(convert(int(s)))

Python: from sys import stdin
for i in stdin:
    if i=="0\n":break
    print(oct(int(i))[2:].translate(str.maketrans("4567","5789")))

Python: while(1):
  n = int(input())
  if n == 0:
    break
  print(oct(n)[2:].translate(str.maketrans('4567', '5789')))

Python: while True:
  n = int(input())
  if n == 0:
    break
  n = oct(n)[2:]
  print(n.translate(str.maketrans('4567', '5789')))

Python: while(1):print(oct(n)[2:].translate(str.maketrans('4567', '5789')))

Python: while True:
  n = int(input())
  if n == 0:
    break
  n = oct(n)[2:]
  print(n.translate(str.maketrans('4567', '5789')))

Python: while True:
    n = input()
    if n == '0':
        break
    if n[-1] in ('7', '8', '9'):
        print(int(n)-((len(n)-1)*2+2))
    elif n[-1] == '5':
        print(int(n)-((len(n)-1)*2+1))
    else:
        print(int(n)-(len(n)-1)*2)

Python: octD = {"0":0, "1":1, "2":2, "3":3, "4":5, "5":7, "6":8, "7":9}

while True :
    n = int(input())
    
    if n == 0 :
        break
    
    else :
        N = list(format(n, "o"))
        # nを8進数に変換
        
        for i in range(len(N)) :
            print(octD[N[i]], end = "")
        print()

Python: while True:
  a=int(input())
  if a==0:
    break

  ans=oct(a)[2:]
  print(ans.translate(str.maketrans({"4":"5","5":"7","6":"8","7":"9"})))

Python: from sys import stdin
readline = stdin.readline


while True:
    old_room_num = int(readline())
    if old_room_num == 0:
        break
    octal = oct(old_room_num)[2:]
    new_room_num = octal.translate(str.maketrans('4567', '5789'))
    print(new_room_num)

Python: from sys import stdin
for i in stdin:
    if i=="0\n":break
    print(oct(int(i))[2:].translate(str.maketrans("4567","5789")))

Python: while True:
  n = int(input())
  if(n == 0):
    break
  print(''.join('01235789'[int(i)] for i in oct(n)[2:]))

Python: #Room Numbers of a Hospital
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0208
#coding: utf-8

num = 1;
sub = 0;
while 0 != num:
    num = int(input());
    f = 0;

    if num == 0:
        break;

    for i in range(1,num+1):
        sub = i % 10;
        if 4 == sub:
            f += 1;
        elif 6 == sub:
            f += 1;
        elif 4 == f % 10:
            f += 1;
        elif 6 == f % 10:
            f += 1;
        f += 1;
    print(f);

Python: a = "0 1 2 3 5 7 8 9".split()
while True:
    N = int(input())
    if N == 0:
        break
    print("".join((a[int(n)] for n in oct(N)[2:])))

Python: def ge(arr):
    for i in range(len(arr)):
        tmp = int(arr[i])
        if tmp >= 4:
            tmp += 1
        if tmp >= 6:
            tmp += 1
        arr[i] = str(tmp)
    return arr


while True:
    n = int(input())
    if n == 0:
        break
    print("".join(ge(list(oct(n))[2:])))

Python: while True:
  n = int(input())
  if not n: break
  n = oct(n)[2:]
  print(n.translate(str.maketrans('4567', '5789')))

Python: print(*[''.join('01235789'[int(i)]for i in oct(int(x))[2:])for x in open(0).read().split()[:-1]],sep='\n')

Python: #Room Numbers of a Hospital
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0208
#coding: utf-8

num = 1;
sub = 0;
while 0 != num:
    num = int(input());
    f = 0;

    if num == 0:
        break;

    for i in range(1,num+1):
        sub = i % 10;
        if 4 == sub:
            f += 1;
        elif 6 == sub:
            f += 1;
        elif 4 == f % 10:
            f += 1;
        elif 6 == f % 10:
            f += 1;
        f += 1;
    print(f);

Python: from sys import stdin
line=stdin.readlines()
for i in line[:-1]:print(oct(int(i))[2:].translate(str.maketrans("4567","5789")))

Python: #Room Numbers of a Hospital
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0208
#coding: utf-8

num = 1;
sub = 0;
while 0 != num:
    num = int(input());
    f = 0;

    if num == 0:
        break;

    for i in range(1,num+1):
        sub = i % 10;
        if 4 == sub:
            f += 1;
        elif 6 == sub:
            f += 1;
        elif 4 == f % 10:
            f += 1;
        elif 6 == f % 10:
            f += 1;
        f += 1;
    print(f);

Python: # AOJ 0208 Room Numbers of a Hospital
# Python3 2018.6.23 bal4u
# 8進数に変換して、01234567を01235789に置き換える

dic = {'0':'0','1':'1','2':'2','3':'3','4':'5','5':'7','6':'8','7':'9'}
while 1:
	n = int(input())
	if n == 0: break
	s = format(n, 'o')
	ans = ''
	for i in range(len(s)): ans += dic[s[i]]
	print(ans)

Python: # Aizu Problem 0208: Room Numbers of a Hospital

import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


    
while True:
    n = int(input())
    if n == 0:
        break
    print(oct(n)[2:].replace('7','9').replace('6','8').replace('5','7').replace('4','5'))

Python: """ Created by Jieyi on 9/20/16. """


def main():
    while True:
        num = int(input())
        if num == 0:
            break

        num = str(oct(num)[2:])
        ans = num.translate(str.maketrans('4567', '5789'))
        print(ans)


if __name__ == '__main__':
    main()

Python: while True:
    num = int(input())

    index = 1
    for n in range(1, num):
        index += 1

        while True:
            str_index = str(index)
            if '4' in str_index or '6' in str_index:
                index += 1
            else:
                break

    print(index)

Python: # AOJ 0208 Room Numbers of a Hospital
# Python3 2018.6.23 bal4u
# 8進数に変換して、01234567を01235789に置き換える

dic = {'0':'0','1':'1','2':'2','3':'3','4':'5','5':'7','6':'8','7':'9'}
while 1:
	n = int(input())
	if n == 0: break
	s = list(format(n, 'o'))
	for i in range(len(s)): s[i] = dic[s[i]]
	print(*s, sep='')

Python: from sys import stdin
l=stdin.readlines()
for i in l[:-1]:print(oct(int(i))[2:].translate(str.maketrans("4567","5789")))