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>
int main(){
	while(1){
		int a;
		std::cin>>a;
		if(a==0)break;
		int g=0;
		for(int i=0;i<a;i++){
			g++;
			int n=10;
			for(int i=1;i<10;i++){
				if(g%n==4||g%n==6||g/n==4||g/n==6)g++;
				n*=10;
			}
		}
		std::cout<<g<<std::endl;
		}
		
		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(std::to_string(count).find("4",0) == -1 && std::to_string(count).find("6",0) == -1){
				i++;
			}
			if(i==n){
				cout << count << endl;
				break;
			}

			count++;
		}

	}
}

C++: 
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    vi v;
    while(n){
      v.push_back(n%8);
      n/=8;
    }
    reverse(all(v));
    rep(i,v.size()){
      if(v[i]>=4)v[i]++;
      if(v[i]>=6)v[i]++;
      cout<<v[i];
    }
    cout<<endl;
  }
}

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)
{

	long long int z,s,d,a,f,g,h,i,j,k;
	scanf("%lld",&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\n",z);
		scanf("%lld",&a);
	}
	return 0;
}

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)
	{
		if(n <= 8)
		{
			a += ex[n] + '0';
			break;
		}
		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 <iostream>
using namespace std;

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

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

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

using namespace std;

int main(){

	int n;
	int tmp;
	string s;

	while(1){

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

		s="";
		
		while(n!=0){
			tmp=n%8;
			if(tmp>=4) tmp++;
			if(tmp>=6) tmp++;
			s+=tmp+'0';
			n/=8;
		}

		for(int i=0;i<s.size()/2;i++){
			swap(s[i],s[s.size()-i-1]);
		}

		cout<<s<<endl;
	}
}

C++: #import<cstdio>
t[]={0,1,2,3,5,7,8,9};
void s(int n){if(n>7)s(n/8);printf("%d",t[n%8]);}
main(){for(int a;scanf("%d",&a),a;puts(""))s(a);}

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

using namespace std;

int judge(char[], char[], char[], int);

int main() {

	int i, n, count;
	char s1[64];
	char s2[2]="4";
	char s3[2]="6";

	while(cin >> n) {
		count=0;
		if(n==0)
			break;
		for(i=1; i<=n; i++) {
			count++;
			count=judge(s1, s2, s3, count);
		}
		cout << count << endl;
	}

	return 0;

}

int judge(char s1[], char s2[], char s3[], int count) {

	sprintf(s1, "%d", count);
	while((strpbrk(s1, s2)!=NULL)||(strpbrk(s1, s3)!=NULL)) {
		count++;
		sprintf(s1, "%d", count);
	}

	return count;

}

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

using namespace std;

int main()
{
	for(int n;cin>>n,n;){
		vector<int> renew;
		while(n){
			int digit=n%8;
			if(digit>=4)	digit++;
			if(digit>=6)	digit++;
			renew.push_back(digit);
			n/=8;
		}
		for(int i=renew.size()-1;i>=0;i--)	cout<<renew[i];
		cout<<endl;
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 27;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define repD(i, n) for(int i = n; i >= 0; i--)


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

int main(){
	ll n;
	while(cin >> n && n){
		ll p = 1;
		while(p * 8LL <= n) p *= 8LL;
		while(p > 0){
			int a = n / p;
			n %= p;
			p /= 8LL;
			cout << nums[a] ;
		}
		cout << endl;
	}
	return 0;
}