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>
using namespace std;


int main()
{
  int n;
  char c[10];
  while(1)
  {
    cin >> n;
    if(!n)
      break;
    for(int i = 0; i < 10; i++)
      c[i] = 50;

    int cnt = 0;
    while(n > 0)
    {
      c[cnt++] = n % 8;
      n /=  8;
    }

    for(int i = 9; i >= 0; i--)
    {
      //cout << i << ":" << (int)c[i] << endl;                                  
      if(c[i] == 50)
        continue;
      if(c[i] >= 5)
        cout << (char)(c[i] + 2 + '0');
      else if(c[i] >= 4)
        cout << (char)(c[i] + 1 + '0');
      else
        cout << (char)(c[i] + '0');
    }
    cout << endl;
  }
}

C++: #include <stdio.h>

#define N 8
int main(void){
    long 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 <iostream>
using namespace std;

typedef long long int LLI;

int n;

bool input() {
  cin >> n;
  if (!n) {
    return false;
  }
  return true;
}

void solve() {
  LLI b = 1;
  LLI k = 0;
  while (n) {
    int m = n % 8;
    if (m < 4) {
      k += m * b;
    } else if (m < 5) {
      k += (m + 1) * b;
    } else {
      k += (m + 2) * b;
    }
    n /= 8;
    b *= 10;
  }
  cout << k << endl;
}

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

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

using namespace std;

int main(){
	int self;
	char str[256];
	char* pt;
	bool flag;
	while(1){
		scanf("%d",&self);
		if(self == 0){break;}
		sprintf(str,"%o",self);
		//printf("%s\n",str);
		//01234567
		//01235789
		for(pt = str;*pt!='\0';pt++){
			if(*pt >= '5'){
				*pt += 2;
			}else if(*pt >= '4'){
				*pt += 1;
			}
		}
		printf("%s\n",str);
	}
	return 0;
}

C++: #include<cstdio>
#include<vector>
#include<algorithm>
#include<sstream>
#include<string>
#include<iostream>
using namespace std;
string conv(int n){
    stringstream ss;
    while(n){
        ss<<n%8;
        n/=8;
    }
    string ret=ss.str();
    reverse(ret.begin(),ret.end());
    return ret;
}
const int l[]={0,1,2,3,5,7,8,9};
int main(){
    int n;
    while(cin>>n,n){
        string str=conv(n);
        for(int i=0;i<str.length();i++){
            cout<<l[str[i]-'0'];
        }
        cout<<endl;
    }
    return 0;
}

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

void ToOctalNumber(int n){
	if(!n)return;
	ToOctalNumber(n >> 3);
	std::cout << ((n&7)<4?n&7:(n&7)==4?5:(n&7)+2);
}

int main(){
	int n;
	while(std::cin >> n, n){
		ToOctalNumber(n);
		std::cout << "\n";
	}
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int n;
string table = "01235789";
string ans;

int main(){
	while (cin >> n&&n){
		ans = "";
		while (n / 8 > 0){
			int num = n % 8;
			ans += table[num];
			n /= 8;
		}
		ans += table[n];
		reverse(ALL(ans));
		cout << ans << endl;
	}
}

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

using namespace std;

void reverse(vector<char>& vec){
	vector<char> tmp;
	for(int i = 0;i < vec.size();i++){
		tmp.push_back(vec[vec.size() - 1 - i]);
	}
	vec.clear();
	vec = tmp;
}


int main(void){
	int n;
	vector<char> ans;
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		while(n != 0){
			ans.push_back((char)('0' + (n % 8)));
			n /= 8;
		}
		reverse(ans);
		for(int i = 0;i < ans.size();i++){
			if('4' <= ans[i]){
				ans[i]++;
			}
			if('6' <= ans[i]){
				ans[i]++;
			}
		}
		for(int i = 0;i < ans.size();i++){
			cout << ans[i];
		}
		cout << endl;
		ans.clear();
	}


	return 0;
}

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

int main(){
	int n,i;
	int count;
	while(1){
		cin >> n;
		count = 0;
		if(n==0){
			break;
		}
		i = 0;
		count = 1;
		while(1){
			if(to_string(count).find("4",0) == string::npos && to_string(count).find("6",0) == string::npos){
				i++;
			}
			if(i==n){
				cout << count << endl;
				break;
			}

			count++;
		}

	}
}

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

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

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

string f(ll n)
{
	string a;
	while(n)
	{
		a += ex[n % 8] + '0';
		n /= 8;
	}
	reverse(a.begin(), a.end());

	return a;
}

int main()
{
	ll n;
	while(cin >> n, n)
	{
		cout << f(n) << endl;
	}
}

C++: #include <stdio.h>
#include <algorithm>
using namespace std;
const int a[8] = { 0, 1, 2, 3, 5, 7, 8, 9 };
int n, s[15];
int main() {
	while(true) {
		scanf("%d", &n);
		if(n == 0) break;
		for(int i = 0; i < 15; i++) {
			s[i] = a[n % 8];
			n /= 8;
		}
		reverse(s, s + 15); bool flag = false;
		for(int i = 0; i < 15; i++) {
			flag = flag || s[i];
			if(flag) {
				printf("%d", s[i]);
			}
		}
		printf("\n");
	}
	return 0;
}

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

int main(){
    int in_num;
    char num_s8[12];
    while(1){
        cin  >> in_num;
        if(in_num == 0){
            break;
        }
        snprintf(num_s8, sizeof(num_s8), "%o", in_num);
        for(int i=0; i<strlen(num_s8); i++){
            if(num_s8[i] == '4'){
                num_s8[i] = '5';
            }
            
            else if(num_s8[i] == '5'){
                num_s8[i] = '7';
            }
            
            else if(num_s8[i] == '6'){
                num_s8[i] = '8';
            }
            else if(num_s8[i] == '7'){
                num_s8[i] = '9';
            }
            
        }
        printf("%s\n", num_s8);
    }
   
    return 0;
}

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

using namespace std;

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

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> buf;
		while(n)
		{
			buf.push_back(n % 8);
			n /= 8;
		}
		reverse(buf.begin(), buf.end());
		for(int i = 0; i < buf.size(); ++i)
		{
			cout << data[buf[i]];
		}
		cout << endl;
	}
}

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