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 <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;

int main(){
	int n;

	stack<int> S;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		while(n > 0){
			S.push(n%8);
			n /= 8;
		}

		while(!S.empty()){
			switch(S.top()){
			case 0:
				printf("0");
				break;
			case 1:
				printf("1");
				break;
			case 2:
				printf("2");
				break;
			case 3:
				printf("3");
				break;
			case 4:
				printf("5");
				break;
			case 5:
				printf("7");
				break;
			case 6:
				printf("8");
				break;
			case 7:
				printf("9");
				break;
			}
			S.pop();
		}
		printf("\n");
	}

    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

int main(){
	int n;
	while(cin >> n, n){
		char s[100];
		sprintf(s, "%o", n);
		char *p = s;
		while(*p){
			cout << "01235789"[*p-'0'];
			p++;
		}
		cout << endl;
	}

	return 0;
}

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

using namespace std;

string convert(int n){ 
        string s = ""; 
        while(n){
                s += n%8 + '0';
                n /= 8;
        }   
        string _s = ""; 
        for(int i = s.size()-1; i >= 0; i--){
                char c = s[i];
                if(c >= '6') c++;
                if(c >= '4') c++;
                _s += c;
        }   
        return _s; 
}

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

C++: #include <iostream>
#include <vector>

using namespace std;

void solve()
{
	char oct[8] = {'0', '1', '2', '3', '5', '7', '8', '9'};
	int n;
	while(cin >> n, n)
	{
		vector<char> Vec;
		while(n)
		{
			Vec.push_back(oct[n % 8]);
			n /= 8;
		}
		for(int i = Vec.size() - 1; i >= 0; --i)
		{
			cout << Vec[i];
		}
		cout << endl;
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include<stdio.h>
int main(void){
   int n, r, w, N;
   scanf("%d", &n);
   while(n){
       if ( n % 8 >= 5 ) N = n / 8 * 10 + n % 8 + 2;
       else if ( n % 8 >= 4 )  N = n / 8 * 10 + n % 8 + 1;
       else N = n / 8 * 10 + n % 8;
       printf("  %d\n", N);
       scanf("%d", &n);
    }
    return 0;
}

C++: tw

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

int main()
{
	int n;
	while(cin >> n){
		if(!n){
			break;
		}
		int bit[100];
		int a=0;
		while(n!=0){
			bit[a++] = n%8;
			if(bit[a-1] >= 4)
				bit[a-1]++;
			if(bit[a-1] >=6)
				bit[a-1]++;
			n/=8;
		}
		for(int i=a-1;i>=0;i--)
			cout << bit[i];
		cout << endl;
	}
	return 0;
}

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

long convert(long n);

int main(void){
  long n;
  while(true){
    cin>>n;
    if(n==0)break;
    cout<<convert(n)<<endl;
  }
  return 0;
}

long convert(long n){
  long order=1;
  long retval=0;
  while(n>0){
    int mod=n%8;
    if(mod>=5){
      mod+=2;
    }
    else if(mod>=4){
      mod+=1;
    }
    retval+=order*mod;
    n=n/8;
    order=order*10;
  }
  return retval;
}

C++: #include<iostream>
using namespace std;
int box[]={0,1,2,3,5,7,8,9};
void oct(int x){
	int a=x%8;
	if(x/8!=0)
	oct(x/8);
	cout<<box[a];
}
int main(){
	int n;
	while(cin>>n,n){
		oct(n);
		cout<<endl;
	}
	return 0;
}

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

using namespace std;

int main(){
  int n,i,c,r[11];
  int ei[8]={1,2,3,5,7,8,9,0};
  while(1){
    cin>>n;
    if(n==0)break;
    
    for(i=0;n>=8;i++){ 
      if(n<8)break;      
      r[i]=n%8;
      n/=8;
    }
    r[i]=n;
    for(;i>=0;i--){
      cout<<ei[r[i]-1];
    }
    cout<<endl; 
  }
  return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)

typedef long long lint;

lint dp[20][2][2];

lint calc(lint N) {
	memset(dp, 0, sizeof(dp));
	
	lint div = 1;
	for_(i,0,18) div *= 10;
	
	dp[19][0][0] = 1;
	
	for_rev(i,19,1) {
		lint d = (N / div) % 10;
		
		for_(j,0,2) for_(k,0,2) {
			if (dp[i][j][k] == 0) continue;
			
			for_(a,0,10) {
				if (j == 0 && d < a) continue;
				int nj = (j == 1 || d > a) ? 1 : 0;
				int nk = (k == 1 || a == 4 || a == 6) ? 1 : 0;
				dp[i - 1][nj][nk] += dp[i][j][k];
			}
		}
		
		div /= 10;
	}
	
	return dp[0][1][1];
}

void solve(lint n) {
	lint lb = 1, ub = (lint)1e15;
	
	while (ub - lb > 1) {
		lint med = (ub + lb) / 2;
		lint c = calc(med);
		
		if (med - c > n) ub = med;
		else lb = med;
	}
	
	cout << lb << endl;
}

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

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef __int64 ll;
//typedef long long ll;
ll n;

int main(){
	while(cin>>n){
		if(!n)return 0;
		ll m=n,d=1,p;
		while(m>7){m/=8;d++;}
		for(int i=d-1;i>=0;i--){
			p=(n/(int)(pow(8,i)+0.1))%8;
			if(p<4)cout<<p;
			else if(p<5)cout<<p+1;
			else cout<<p+2;
		}
		cout<<endl;
	}
}

C++: #include<iostream>
#include<string>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

string func(long long n){
	string res;
	int size=log(n)/log(8);
	for(int i=size;i>=0;i--){
		char ch=(char)((n/(int)pow(8,i))+'0');
		if(ch=='4')ch='5';
		else if(ch=='5')ch='7';
		else if(ch=='6')ch='8';
		else if(ch=='7')ch='9';
		res+=ch;
		n%=(int)pow(8,i);
	}
	return res;
}
int main(){
	long long n;
	while(cin>>n,n){
		cout<<func(n)<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <math.h>

using namespace std;

int main(){
  char newnum[8] = {0,1,2,3,5,7,8,9};
  long input_num,output_num;
  int count_num;
  while(cin >> input_num && input_num != 0){
    output_num = 0;
    count_num = 0;
    while(input_num != 0){
      output_num += newnum[input_num % 8] * pow(10,(double)count_num);
      input_num /= 8;
      //      cout << output_num << " " ;
      count_num++;
    }
    cout << output_num;
    cout << endl;
  }

}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

void f(int n){
	if(n>8)f(n/8);
	n%=8;
	if(n<4)cout<<n;
	else if(n==4)cout<<5;
	else cout<<n+2;
}

int main() {
	int n;
	while(n=in()){
		f(n);
		cout<<endl;
	}
	return 0;
}