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++: //32
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    char o[10];
    sprintf(o,"%o",n);
    for(int i=0;o[i];i++){
      cout<<char(o[i]+(o[i]>='4')+(o[i]>='5'));
    }
    cout<<endl;
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
  int n;
  long long ans, d;
  int list[] = {0,1,2,3,5,7,8,9};
  while(cin >> n, n){
    ans=0, d=1;
    while(n!=0){
      ans += d*list[n%8];
      d*=10;
      n/=8;
    }
    cout << ans << endl;
  }
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
string a[8]={"0","1","2","3","5","7","8","9"};
string func(int in){
  if(!in)return "0";
  else {
    string out="";
    while(in){
      out=a[in%8]+out;
      in/=8;
    }
    return out;
  }
}  
int main(){
  int in;
  while(cin>>in,in){
    cout<<func(in)<<endl;
  }
}

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

using namespace std;
  
int main(){

	int n;
	string ans;
	string bdata=("01234567");
	string adata=("01235789");
	while(1){

		cin>>n;
		if(n==0) break;
		ans="";

		while(n!=0){
			ans+=(n%8)+'0';
			n/=8;
		}

		for(int i=0;i<ans.length();i++){
			ans[i]=adata[bdata.find(ans[i])];
		}
		
		for(int i=ans.length()-1;i>=0;i--) cout<<ans[i];
		cout<<endl;
	}

	return 0;
}

C++: #include<cstdio>
int main(){
  int i;
  int a[11]={1},n;
  char s[9]="01235789";
  for(i=1;i<11;++i)
    a[i]=a[i-1]*8;
  while(scanf("%d",&n),n){
    for(i=0;a[i]<=n;++i);
    for(--i;i>=0;--i){
      printf("%c",s[n/a[i]]);
      n%=a[i];
    }
    puts("");
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n;
	string s="01235789";
	while(1){
		cin>>n;
		if(n==0) break;
		string ans="";
		bool f=false;
		for(int i=10;i>=0;i--){
			int now=n/(int)pow((int)8,i);
			if(now!=0) f=true;
			//cout<<now<<" ";
			if(f){
				ans+=s[now];
				//cout<<s[now]<<" ";
			}
			n%=(int)pow((int)8,i);
		}
		//cout<<endl;
		o(ans);
	}
}

C++: #include <iostream>
using namespace std;
int  main(){
  char s[]={'0','1','2','3','5','7','8','9'};
  string a;
  int n;
  cin>>n;
  for(a="";n>0;n=n/8)
      a=s[n%8]+a;
  cout<<a<<endl;
}

C++: #include<iostream>
using namespace std;
int main(){
long n,d[10],i,j,a,b[8]={0,1,2,3,5,7,8,9};
while(cin>>n){
if(n==0)break;
for(i=0;;i++){
a=n/8;
d[i]=n%8;
n=a;
if(n==0)break;
}
for(j=i;j>=0;j--)cout<<b[d[j]];cout<<endl;
}
return 0;
}

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

using namespace std;

int main() {
	long long int n;
	string kazu = "01235789";
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		string b = "";
		while (n != 0) {
			b += kazu[n%8];
			n /= 8;
		}
		for (int i = b.size()-1; i >= 0; i--) {
			cout << b[i];
		}
		cout << endl;
	}
	return 0;
}

C++: #import<cstdio>
void s(int n){if(n>7)s(n/8);printf("%d",n%8<4?n%8:n%8<6?n%8+1:n%8+2);}main(){for(int a;scanf("%d",&a),a;puts(""))s(a);}

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) == -1 && to_string(count).find("6",0) == -1){
				i++;
			}
			if(i==n){
				cout << count << endl;
				break;
			}

			count++;
		}

	}
}

C++: #include<iostream>

#include<vector>

using namespace std;

int main()
{
	for(;;)
	{
		int N;
		cin >> N;
		if(N == 0)
		{
			break;
		}

		vector<int> vobj;
		for(;;)
		{
			if(N <= 7)
			{
				vobj.push_back(N);
				break;
			}
			vobj.push_back(N % 8);
		
			N = N / 8;


		}

		for(int i = vobj.size() -1; i >= 0; i--)
		{
			int outputNo;
			outputNo = vobj[i];
			if(outputNo == 4)
			{
				outputNo = 5;
			}
			else if(outputNo == 5)
			{
				outputNo = 7;
			}
			else if(outputNo == 6)
			{
				outputNo = 8;
			}
			else if(outputNo == 7)
			{
				outputNo = 9;
			}
			cout << outputNo;

		}
		cout << endl;

	}



}

C++: #include <iostream>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;

int main(){
	int n, num[] = {0,1,2,3,5,7,8,9};
	while(cin >> n, n) {
		long long a=0, d=1;
		while(n) {
			a += num[n%8]*d;
			d *= 10;
			n /= 8;
		}
		cout << a << endl;
	}
	return 0;
}

C++: #include<stdio.h>
int table[]={0,1,2,3,5,7,8,9};
int output[100];
int now;
int main(){
	int a;
	while(scanf("%d",&a),a){
		now=0;
		while(a>0){
			output[now++]=table[a%8];
			a/=8;
		}
		for(int i=now-1;i>=0;i--)printf("%d",output[i]);
		printf("\n");
	}
}

C++: #include <iostream>
using namespace std;
int main(){
  int i;
  char s[10];
  while(cin>>i,i){
    sprintf(s,"%o",i);
    for(i=0;s[i]!='\0';i++){
      if(s[i]>='4')s[i]++;
      if(s[i]>='6')s[i]++;
}
    printf("%s\0",s);
}
}

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

int num(int x) {
	if (x == 4)return 5;
	else if (x > 4)return x + 2;
	else return x;
}

int main() {
	int n;
	while (cin >> n, n) {
		stack<int>st;
		while (n > 7) {
			int a = (n % 8);
			a = num(a);
			st.push(a);
			n /= 8;
		}
		int a = num(n);
		st.push(a);

		int b = st.size();
		for (int i = 0;i < b;i++) {
			cout << st.top();
			st.pop();
		}
		cout << endl;
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

int main(){
	const char oct[] = {'0','1','2','3','5','7','8','9'};
	ll n;
	while(~scanf("%lld",&n)){
		if(n==0) break;
		char buf[11];
		sprintf(buf,"%llo",n);

		for(int i=10;i>=0;i--){
			if(buf[i]-'0' < 0 || buf[i]-'0' >= 8) continue;
			buf[i] = oct[buf[i]-'0'];
		}
		printf("%s\n",buf);
	}
}

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;j>=0;j--)


    cout << endl;
  }

}

C++: #include <iostream>
using namespace std;
int main() {
  int i;
  char s[10];
  while(cin>>i,i){
    sprintf(s,"%o",i);
    for(i=0;s[i]!='\0';i++){
      if(s[i]>='4')s[i]++;
      if(s[i]>='6')s[i]++;
}
    printf("%s\n",s);
}
}