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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int n;cin>>n,n;){
		string s;
		while(n){
			s=s+char('0'+n%8);
			n/=8;
		}
		reverse(allof(s));
		rep(i,s.size()){
			if(s[i]=='4')
				s[i]++;
			else if('5'<=s[i])
				s[i]+=2;
		}
		cout<<s<<endl;
	}
	
	return 0;
}

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

int main() {
  int n;

  int num[8] = {0, 1, 2, 3, 5, 7, 8, 9};
  while (cin >> n, n) {
    vector<int> ans;
    while (n) {
      ans.push_back(n % 8);
      n /= 8;
    }

    reverse(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); ++i) {
      cout << num[ans[i]];
    }

    cout << endl;
  }
}

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

 const int table[] = { 1,2,3,4,5,6,7,8,9 };
 void surgeon(int x)
 {
  if(x>=8)
  {
  surgeon(x/8);
  }
 return(table[x%8]);
 }
 int main()
 {
 int x;
 while(cin>>x, x>0)
 {
  surgeon(n);
  cout<<endl;
  }
 return 0;
}

C++: #include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

const int MAX_N = 1000000009;
vector<int> ans;

bool ok(int a) {
    while(a) {
        if(a%10 == 4 || a%10 == 6) return false;
        a /= 10;
    }
    return true;
}
void init() {
    rep(i,MAX_N) {
        if(!i) continue;
        if(ok(i)) ans.pb(i);
    }

}
int main() {
    init();
    int n;
    while(cin>>n) {
        if(!n) break;
        cout<<ans[n-1]<<endl;

    }
    return 0;
}

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

using namespace std;

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

C++: #include<stdio.h>
int main()
{
	int n;
	char*p,s[32];
	while(scanf("%d",&n),n)
	{
		sprintf(s,"%o",n);
		for(p=s;*p;++p)if(*p>'4')*p+=2;else if(*p>'3')*p+=1;
		puts(s);
	}
	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]==0) break

if(ans[i]>=4) ans[i]++;
if(ans[i]>=6) ans[i]++;

}
printf("%s\n",ans);
}
	return 0;
}

C++: #include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[1000001];//動的計画法
int prime[1000001];
int main(){
    int table[]={0,1,2,3,5,7,8,9};
    int num,keta,ans[100];
    while(cin>>num,num){
        keta=0;
        while(num>0){
            ans[keta++]=table[num%8];
            num/=8;
        }
        for(int i=keta-1;i>=0;i--) cout<<ans[i];
        cout<<endl;
    }
    return 0;
}

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

int main()
{
	long long s;
	while(cin >> s, s)
	{
		string ret;
		while(s)
		{
			ret+=s%8LL+'0';
			s/=8LL;
		}
		
		reverse(ret.begin(), ret.end());
		for(int i=0; i<ret.size(); i++)
		{
			int t=ret[i]-'0';
			if(t>=5) t+=2;
			else if(t>=4) t+=1;
			
			
			ret[i]=t+'0';
		}
		
		cout << ret << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
using namespace std;int t;string e(int a){string ret;while(a){t=a%8;t+=(t>4)+(t>3);a/=8;ret+='0'+t;}reverse(ret.begin(),ret.end());return ret;}int main(){while(cin>>t&&t)cout <<e(t)<<endl;}

C++: #include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int main(){
    int time=0;
    int n;
    ll ans=0;
    while(cin>>n){
        ans=0;
        if(n==0)break;
        time=0;
        
        for(int i=9;i>=1;i--){
            time=0;
            while(n>=pow(8,i)){
                time++;
                if( time!=4 && time!=6 )
                    n-=pow(8,i);
                ans+=pow(10,i);
            }
        }
        for(int i=1;i<=9;i++){
            if(n==0)break;

            if(i!=4 && i!=6){
                n--;
            }
            ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
int main() {
  int P[8] = {0, 1, 2, 3, 5, 7, 8, 9};
  long long A;
  while (cin >> A, A) {
    long long q = 1, ans = 0;
    while (A != 0) {
      ans += q * P[A % 8];
      q *= 10;
      A /= 8;
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

char num[12];
int upper;
int len=12;
int in;
int main () {

  while ( true ) {
    cin >> in;

    if ( in == 0 )
      break;


    upper = 0;
    
    bool carry = false;
    for ( int i=0; i<len; i++ ) {
      num[i] = 0;
    }

    for ( int i=11; i>=0; i-- ) {
      
      num[i] = in%8+'0';
      in = in/8;
    }
  
    int count = 0;
    while ( num[count] == '0' )
      count++;
  

    for ( int i=count;i <len; i++ ) {
      if ( num[i] == '4' )
	cout << '5';
      else if ( num[i] >'4' )
	cout << (char)(num[i]+2);
      else
	cout << num[i];
    }
    cout << endl;
  }

}