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 <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	for (long u = 0; u < 30000; u++)
	{
		long long n = 0;
		cin >> n;
		if (n == 0)
		{
			break;
		}

		int co = 0;

		for (long long i = 1; i < n + 1; i++)
		{
			ostringstream p;
			p << i;
			string pp;
			pp = p.str();

			int k = 0;
			k = pp.size();

			for (int j = 0; j < k; j++)
			{
				if (pp.substr(j,1) == "4")
				{
					co += 1;
				}
				else if (pp.substr(j,1) == "6")
				{
					co += 1;
				}
			}
		}

		cout<< " "  << co << " "<< n + co << endl;
	}
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
 
int main()
{
vector<string> v(8);
string s;
int n,i;
 
for(i=0;i<8;i++) v[i] = '0'+i+(i>=4)+(i>=6);
 
while(cin>>n,n){
 s = "";
 while(n>0){
  s += v[n%8];
  n /= 8;
 }
 reverse(s.begin(),s.end());
 cout<<s<<endl;
}
 
return 0;
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int num[] = {0, 1, 2, 3, 5, 7, 8, 9};

    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        long long tmp = 1;
        long long ret = 0;
        while(n > 0){
            ret += tmp * num[n%8];
            n /= 8;
            tmp *= 10;
        }
        cout << ret << endl;
    }
}

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

void solve(int n){
	if(!n)
		return;
	solve(n/8);
	int tmp = n%8;
	switch(n%8){
		case 0:
		case 1:
		case 2:
		case 3:
			break;
		case 4:
			tmp++;
			break;
		default:
			tmp += 2;
	}
	cout << tmp;
}

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

C++: #include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

typedef long long ll;


int fourOrSixPlace(ll num){
	int idx=-1;
	int cnt=0;
	while(num>0){
		if(num%10==6||num%10==4){
			idx=cnt;
		}
		num/=10;
		cnt++;
	}
	return idx;
}

int main(){

	//int cc=0;
	//for(ll i = 1; i <= 100000; i++){
	//	int ret=fourOrSixPlace(i);
	//	if(ret!=-1)
	//		cc++;
	//}
	//cout<<cc<<endl;
	ll n;
	while(cin>>n&&n!=0){
		ll cnum=0;
		ll cnt=0;
		while(1){
			if(cnum>10000000000LL){
				return 0;
			}
			cnum+=100000;
			if(cnum>n)
				break;
			int ret=fourOrSixPlace(cnum);
			if(ret==-1){
				n+=67232;
			}
			else{
				n+=67232;
				cnum+=(ll)pow(10.0,ret);
				n+=(ll)pow(10.0,ret);
			}
		}

		if(true){
			cnum-=100000;
			cnum++;
			for(ll i = cnum; i <= n; i++){
				int ret=fourOrSixPlace(i);
				if(ret!=-1){
					if(ret==0){
						n++;
					}
					else{
						n+=(ll)pow(10.0,ret);
						i+=(ll)pow(10.0,ret);
					}
				}
			}
		}
		cout<<n<<endl;
	}


	return 0;
}

C++: #include <stdio.h>

#define N 8
int main(void){
    int n,q, dig;
    int num[]={0,1,2,3,5,7,8,9};
     
    while (scanf("%d", &n), n!=0){
        dig = 0;        
        q=0;
        while (n){
            q += n%N;
            q *= 10;
            n /= N;
            dig++;
        }
        q /= 10;
        if (dig){
            while (dig--){
                printf("%d", num[q%10]);
                q /= 10;
            }
        } else printf("0");
        printf("\n");
    }
     
    return 0;
}

C++: #include <bits/stdc++.h>
#define INF (1<<29)
#define all(c) (c).begin(),(c).end()
#define pb(c) push_back(c)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int getv(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 << getv(n%8);
}

int main(){
  ios::sync_with_stdio(false);
  int n;

  while(cin >> n && n){
    convert(n);
    cout << endl;
  }


}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
 
int main()
{
vector<string> v(8);
string s;
int n,i;
 
for(i=0;i<8;i++) v[i] = '0'+i+(i>=4)+(i>=5);
 
while(cin>>n,n){
 s = "";
 while(n>0){
  s += v[n%8];
  n /= 8;
 }
 reverse(s.begin(),s.end());
 cout<<s<<endl;
}
 
return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  int newnum[8] = {0,1,2,3,5,7,8,9};
  long input_num;

  int count_num;
  while(cin >> input_num && input_num != 0){
    //    output_num = 0;
    count_num = 0;
  long output_num[13]={0};
    while(input_num != 0){
      output_num[count_num] = newnum[input_num % 8];
      input_num /= 8;
	    //input_num = (input_num-input_num % 8)/8;
      //      cout << output_num << " " ;
      count_num++;
    }
    /*
    for(int j=count_num-1;j>0;j--){
      output_num[j-1] += output_num[j] * 10;
      //      cout << output_num[j] << " ";
    }
    cout << output_num[0];
    */

    for(int j=count_num-1;j>=0;j--){
      cout << output_num[j] ;
    }
    

    cout << endl;
  }

}

C++: #include <cstdio>
#include <string>


int main(){
    char o[] = {'0','1','2','3','5','7','8','9'};
    char res[255];
    long long n = 10;

    while(scanf("%lld", &n) != EOF){
        if(n == 0) break;
        sprintf(res, "%llo", n);

        for(int i = 0; i < 255; i++){
            if(res[i] == '\0') break;
            res[i] = o[res[i] - '0'];
        }

        printf("%s\n", res);
    }

    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back

string o(ll n){
  string ret;
  while(n){
    ret+='0'+n%8;
    n/=8;
  }
  reverse(ret.begin(),ret.end());
  return ret;
}

main(){
  ll n;
  while(cin>>n,n){
    string str=o(n);

    rep(i,str.size()){
      if(str[i]>'4')str[i]+=2;
      else if(str[i]>'3')str[i]+=1;
    }
    cout<<str<<endl;
  }
}

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

    int n;
    while(cin>>n,n){
        string e,f;
        //nを8進数に変換
        for(int i=0;;i++){
            e+=(n%8)+'0';
            n/=8;
            if(n==0)break;
        }
        //reverse
        for(int i=0;i<e.size();i++){
            f+=e[e.size()-i-1];
        }
        //'4'以上で++,さらにその状態で'6'以上なら++
        for(int i=0;i<f.size();i++){
            if(f[i]>='4')f[i]++;
            if(f[i]>='6')f[i]++;
        }
        cout<<f<<endl;
    }
    return 0;
}

C++: #include <cstdio>

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

int b;

long long retans(int bef){
  if(bef < 8){
    return a[bef];
  }else{
    long long ans = a[bef % 8];
    ans += retans(bef / 8) * 10;
    return ans;
  }
}

int main(){
  for(;;){
    scanf("%d", &b);
    if(b == 0){
      break;
    }else{
      long long pri = retans(b);
      printf("%lld", pri);
    }
  }
}