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, ""))
	}
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int main(){

  long long int n,result,n8,blank,i;

  while(cin>>n,n){
    
    result=0;
    for(i=20;i!=-1;i--){
      
      n8=pow(8,i);
      blank=n/n8;
      if(blank>=4) blank++;
      if(blank>=6) blank++;
      result+=blank*pow(10,i);
      n=n%n8;
      
    }
    
    cout<<result<<endl;

  }
  
  return 0;

}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	ll a;
	int q[8]={0,1,2,3,5,7,8,9};
	while(cin>>a,a){
		string s="";
		while(a){
			s=(char)(q[a%8]+'0')+s;
			a/=8;
		}
		cout<<s<<endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int getValue(int x) {
	if (x == 4)
		return 5;
	return (x < 4) ? x : x + 2;
}
void convert(int n) {
	if (n == 0)
		return;
	convert(n / 8);
	cout << getValue(n % 8);
}
main() {
	int n;
	while( cin >> n && n ) {convert(n); cout << endl;}
}

C++: #include <iostream>
#include <string>
using namespace std;

int main()
{
	int n;
	int power[ 10 ];
	power[ 0 ] = 1;
	for( int i = 1; i < 10; ++i ){
		power[ i ] = power[ i - 1 ] * 8;
	}

	while( cin >> n && n ){
		string ans;
		for( int i = 9; i >= 0; --i ){
			int d = n / power[ i ];
			n %= power[ i ];
			if( ans.empty() && d == 0 ) continue;
			if( d >= 4 ) ++d;
			if( d >= 6 ) ++d;
			ans += (char)( d + '0' );
		}
		cout << ans << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
 
int main(){
	int set[] = { 0, 1, 2, 3, 5, 7, 8, 9 };
	int n;
	long ans,keta;
    while(1){
        cin >> n;
        if(n == 0){
        	break; 
     	}
        ans = 0;
        keta = 1;
        while(n != 0){
            ans += keta * set[n%8];
            keta *= 10;
            n /= 8;
        }
        cout << ans << endl;
    }
}

C++: #include <iostream>
#include <string>
#include <cstring>
#include <cmath>

using namespace std;

string toOct(long long  d)
{
	char c[30];
	string s = "";
	
	sprintf_s(c, "%o", d);
	s += c;

	return s;
}


string solve(long long  n)
{
	char c[30];
	string s;

	s = toOct(n);

	for( int i = 0; i < (int)s.length(); i++)
	{
		if( s[i] >= '4' )
			s[i] += '1' - '0';

		if( s[i] >= '6' )
			s[i] += '1' - '0';
	}

	return s;
}


int main()
{
	long long n;

	while( cin >> n, n)
	{
		cout << solve(n) << endl;
	}

	return 0;
}

C++: #include <iostream>
using namespace std;

int trtable[] = {0, 1, 2, 3, 5, 7, 8, 9};

void solve(int n){
	if(n > 8) solve(n / 8);
	cout << trtable[n % 8];
	return;
}

int main(){
	int n;
	while(cin >> n, n){ 
		solve(n);
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main(void){
  int n;
  while(cin>>n,n){
    char sc[20];
    sprintf(sc,"%o",n);
    string s1=string(sc);
    for(int i=0;i<s1.size();++i){
      char c=s1[i];
      if(c>='4')++c;
      if(c>='6')++c;
      cout<<c;
    }
    cout<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <cmath>

using namespace std;

string toOct(long long  d)
{
	char c[30];
	string s = "";
	
	sprintf_s(c, "%o", d);
	s += c;

	return s;
}


string solve(long long  n)
{
	char c[30];
	string s;

	s = toOct(n);

	for( int i = 0; i < (int)s.length(); i++)
	{
		if( s[i] >= '4' )
			s[i] += '1' - '0';

		if( s[i] >= '6' )
			s[i] += '1' - '0';
	}

	return s;
}


int main()
{
	long long n;

	while( cin >> n, n)
	{
		cout << solve(n) << endl;
	}

	return 0;
}

C++: #include <iostream>
using namespace std;

int main(void){
    int room[8] = {0,1,2,3,5,7,8,9},n;
    int newroom[10],i;
    
    while(cin >> n ,n){
        for(i = 0 ;; i++){
            int nn = n / 8;
            newroom[i] = n % 8;
            n = nn;
            if(!n) break;
        }
        
        for(int j = i ; j >= 0 ; j--) cout << room[newroom[j]];
        cout << endl;
    }
    
    return 0;
}

C++: #include <stdio.h>
 
int main(void) {
	int i;
char ans[10];
while(scanf("%d",&i),i){
sprintf(ans,"%o",i);
for(i=0;i<10;i++){
if(ans[i]>=4) ans[i]++;
if(ans[i]>=6) ans[i]++;
if(ans[i]==0) break
}
printf("%s\n",ans);
}
	return 0;
}

C++: // 0, 1, 2, 3, 5, 7, 8, 9を用いた8進表現に変換するだけ
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int ref[8] = {0, 1, 2, 3, 5, 7, 8, 9};
int n;

int main(){
    while(cin >> n, n){
        vector<int> decode;
        while(n != 0){
            decode.push_back(ref[n%8]);
            n /= 8;
        }

        reverse(decode.begin(), decode.end());
        for(int x : decode)     cout << x;
        cout << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;

int main(){
	char *hoge = "01235789";
	int kyu;
	int shinketa;
	char shin[10];
	
	while(cin>>kyu,kyu){
		shinketa=0;
		do{
			shin[shinketa]=hoge[kyu % 8];
			shinketa++;
			kyu /= 8;
		}while(kyu);
		while(shinketa--) cout<<shin[shinketa];
		cout<<endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
void solve(int);
int main(){
  int n;
  while(cin >> n && n){
    solve(n);
    cout << endl;
  }
}
void solve(int n){
  if(n == 0) return;
  solve(n/8);
  int a=n%8;
  cout << (a==4?5:(a>4?a+2:a));
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
char h[]="01235789";
main(){
  while(1){
    ll n;
    scanf("%lld",&n);
    if(!n) break;
    ll a=0;
    ll k=1;
    while(n>0){
      a += (k*(n%8));
      k*=10;
      n/=8;
    }
    char r[15]={};
    int i=0;
    while(a>0){
      r[i]=a%10;
      a/=10;
      ++i;
    }
    for(int j=i-1;j>-1;j--) printf("%c",h[r[j]]);
    puts("");
  }
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int main() {
	long long a[10], c = 1, d, e = 0;
	int b = 0;
	while (c <= 1000000000) {
		a[b] = c;
		b++;
		c *= 8;
	}
	while (cin >> d&&d != 0) {
		e = 0;
		int f = 0;
		for (int i = b-1; i >= 0; i--) {
			f = 0;
			if (a[i] <= d) {
				while (a[i] <= d) {
					f++;
					d -= a[i];
				}
				if (f <= 3)
					e += (pow(10, i)*f);
				else if (f == 5)
					e += (pow(10, i)*(f + 2));
				else if (f < 6)
					e += (pow(10, i)*(f + 1));
				else if(f>=6)
					e += (pow(10, i)*(f + 2));
			}
		}
		cout << e << endl;
	}
}

C++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int table[] = { 0,1,2,3,5,7,8,9 };
	unsigned long long n;
	while (cin >> n, n) {
		vector<int>out;
		while (n > 0) {
			out.push_back(table[n % 8]);
			n /= 8;
		}
		for (int i = out.size() - 1; i >= 0; i--)cout << out[i];
		cout << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n,d[99]; while(cin>>n,n){
		int d[8]={0},c=0;
		while(n>0){
			d[c++]=n%8;
			n/=8;
		}
		while(c--)cout<<"01235789"[d[c]];cout<<endl;
	}
	return 0;
}