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<vector>
using namespace std;
int t[] ={0,1,2,3,5,7,8,9};
vector<int> u;
int main(){
  int n;
  while(cin>>n&&n){
    u.clear();
    while(n>0){
      u.push_back(t[n%8]);
      n/=8;
    }
    for(int i=u.size()-1;i>=0;i--)cout<<u[i];
    cout<<endl;
  }
  return 0;
}

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

int main(){
  int no, i;
  stack<int> sum;
  while(cin >> no, no) {
      for( i = 1;no > 8; i*=10){
	sum.push(no % 8);
	no /= 8;

      }
      sum.push(no);
      while(sum.size()) {
	no = sum.top();
	if(no == 4) no++;
	else if(no  >= 5) no+=2;
	cout << no;
	sum.pop();
      }
      cout << endl;
  }
  return 0;
}

C++: #include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,f,g,h=1,i,j,k;
	long long int z,s,d;
	scanf("%d",&a);
	while(a!=0){
		h=1;
		s=0;
		i=-1;
		z=0;
		d=a;
		while(1){
			i++;
			s=d%8;
			d=d/8;
		//	printf("%lld\n",s);
			if(s==4)
				s+=1;
			else if(s>4)
				s+=2;
			s*=h;
			z+=s;
			h*=10;
			if(d<8)
				break;
		}
		if(d==4)
			d+=1;
		else if(d>4)
			d+=2;
		d*=h;
		z+=d;
		printf("%lld",z);
		scanf("%d",&a);
	}
	return 0;
}

C++: #include<stdio.h>
int main() {
int a,b,c;
int x[8]={0,1,2,3,5,7,8,9};
while(scanf("%d",&a),a) {
c=1;b=0;
while(a) {
b+=x[a&7]*c;
c*=10;a=a>>3;
}
printf("%d\n",b);
}
}

C++: #include <cstdio>

int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		int t[10], d;
		for (d = 0; n; ++d, n /= 8)
			t[d] = n % 8;
		for (int i = d-1; i >= 0; --i)
			printf("%d", t[i] >= 5 ? t[i]+2 : t[i] == 4 ? t[i]+1 : t[i]);
		printf("\n");
	}

	return 0;
}

C++: #include<iostream>
#include<cmath>
#include<string>
using namespace std;
int main(void){
  int n,t,c;
  long double a[15];
  a[10] = pow(8.0,10.0);
  a[9]  = pow(8.0,9.0);
  a[8]  = pow(8.0,8.0);
  a[7]  = pow(8.0,7.0);
  a[6]  = pow(8.0,6.0);
  a[5]  = pow(8.0,5.0);
  a[4]  = pow(8.0,4.0);
  a[3]  = pow(8.0,3.0);
  a[2]  = pow(8.0,2.0);
  a[1]  = pow(8.0,1.0);
  a[0]  = pow(8.0,0);
  while(cin >> n,n){
    string ans;
    for(int i = 10;i >= 0; i--){
      if((int)a[i] <= n){
	t = i;
	break;
      }
    }
    for(int i = t;i >= 0; i--){
      c = n / (int)a[i];
      n -= c * (int)a[i];
      if(c == 0) ans += "0";
      else if(c == 1) ans += "1";
      else if(c == 2) ans += "2";
      else if(c == 3) ans += "3";
      else if(c == 4) ans += "5";
      else if(c == 5) ans += "7";
      else if(c == 6) ans += "8";
      else if(c == 7) ans += "9";
      else ans += "F";
    }
    cout << ans << endl;
  }
}

C++: #include <iostream>

using namespace std;

int main(){
  char 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;j>0;j--){
      output_num[j-1] += output_num[j] * 10;
      //      cout << output_num[j] << " ";
    }

    cout << output_num[0];
    cout << endl;
  }

}

C++: #include<stdio.h>
int main() {
long long a,b,c;
int x[8]={0,1,2,3,5,7,8,9};
while(scanf("%d",&a),a) {
c=1;b=0;
while(a) {
b+=x[a&7]*c;
c*=10;a=a>>3;
}
printf("%d\n",b);
}
}

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

#define REP(i,n) for(int i=0;i<(int)(n);++i)

int main() {
  for (int n; cin >> n, n; ) {
      const string digit = "01235789";
      string ans;
      while (n) {
          ans = digit[n % 8] + ans;
          n /= 8;
      }
      cout << ans << endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int getValue(int n){
	if(n==4) return 5;
	return (n<4)? n:n+2;
}

void convert(int n){
	if(!n) return;
	convert(n/8);
	cout << getValue(n%8);
}

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

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    map<int,char> m;
    m[0] = '0';
    m[1] = '1';
    m[2] = '2';
    m[3] = '3';
    m[4] = '5';
    m[5] = '7';
    m[6] = '8';
    m[7] = '9';
    while (cin >> N, N) {
        string ans;
        while (N) {
            int mod = N % 8;
            ans = m[mod] + ans;
            N /= 8;
        }
        cout << ans << endl;
    }

    return 0;
}

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


void solve(int n) {
  int mod = (int)pow(8.0,10.0);
  bool start = false;
  while(mod != 0) {
    int x = n / mod;
    if(x != 0) start = true;
    if(start) {
      int res = x;
      if(res >= 4) res++;
      if(res >= 6) res++;
      cout << res;
      n -= x * mod;
    }
    mod /= 8;
  }
  cout << endl;
}

int main() {
  int n;
  while(cin >> n,n) {
    solve(n);
  }
}

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 <cmath>
using namespace std;
typedef long long ll;
int table[] = {0,1,2,3,5,7,8,9};

int main(){
  ll n;

  while(cin >> n,n){
    ll e = 1,ans = 0;
    while(1){
      int m = n%8;
      ans += e*table[m];
      e *= 10;
      n /= 8;
      if(n == 0)break;
    }
    cout << ans << endl;
  }
}

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

long long int solve(long long int N) {
    string s = to_string(N);
    int len = s.length();
    
    long long int dp[15][2] = {};
    dp[0][0] = 1;
    for(int i=0; i<len; i++) {
        for(int j=0; j<2; j++) {
            int lim = j ? 9 : s[i] - '0';
            for(int x=0; x<lim+1; x++) {
                if(x == 4 || x == 6) continue;
                dp[i+1][j || x < lim] += dp[i][j];
            }
        }
    }
    
    long long int ret =  dp[len][0] + dp[len][1] - 1;
    return ret;
}


int main(void){
    // Your code here!
    int N;

    while(cin >> N, N) {
        long long int ub = 1LL << 40, lb = 0;
        while(ub - lb > 1) {
            long long int mid = (ub + lb) / 2;
            long long int val = solve(mid);
            
            if(val >= N) ub = mid;
            else lb = mid;
        }
        cout << ub << endl;
    }
    return 0;
}

C++: #include<stdio.h>
int i,j;
int k[10];
int ck;
int n;

int main(){
	while(1){
		scanf("%d",&n);
		if(n==0)return 0;
		ck=0;
		while(n>=1){
			if(n%8<=3)k[ck++]=n%8;
			else if(n%8<=4)k[ck++]=n%8+1;
			else k[ck++]=n%8+2;
			n/=8;
		}
		for(i=ck-1;i>=0;i--){
			printf("%d",k[i]);
		}
		printf("\n");
	}
}

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;
  }

}