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>

int main()
{
	int n,i,c;
	char s[16];
	while(scanf("%d",&n),n)
	{
		sprintf(s,"%o",n);
		for(i=0; c=s[i]; i++)
		{
			c-=48;
			printf("%d",c+c/4+c/5);
		}
		printf("\n");
	}
}

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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0208

bool hated(int x) {
	while (x > 0) {
		if (x % 10 == 4 || x % 10 == 6) return true;
		x /= 10;
	}
	return false;
}

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) break;
		int ans = 1;
		for (int i = 0; i < n - 1; i++) {
			ans++;
			while (hated(ans)) ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	while(1)
	{
		vector<int> vec;
		int n;
		cin >> n;
		if(n==0)break;
		while(1)
		{
			vec.pb(n%8);
			if(n<8)break;
			n/=8;
		}
		reverse(vec.begin(),vec.end());
		for(int i=0;i<vec.size();i++)
		{
			if(vec[i]==4)
			{
				vec[i]++;
			}
			else if(vec[i]==5||vec[i]==6||vec[i]==7)
			{
				vec[i]+=2;
			}
		}
		for(int i=0;i<vec.size();i++)
		{
			cout << vec[i];
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

int main(){
	
	long long int INF = 10000000000000000;
	
	long long int sum[16][10];
	
	for(int i = 0; i < 15; i++){
		for(int j = 0; j < 10; j++){
			sum[i][j] = 0;
		}
	}
	sum[1][1] = 1;
	
	for(int dig = 1; dig < 15; dig++){
		for(int i = 2; i < 10; i++){
			sum[dig][i] = sum[dig][i - 1];
			if(i != 4 && i != 6){
				sum[dig][i] += sum[dig][1];
			}
		}
		sum[dig + 1][1] = sum[dig][9] + sum[dig][1];
	}
	
	for(int i = 0; i < 15; i++){
		sum[i][4] = INF;
		sum[i][6] = INF;
	}
	
	long long int n;
	
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
		
		int dig_start;
		
		for(int i = 1; i < 15; i++){
			if(n < sum[i][1]){
				dig_start = i - 1;
				break;
			}
		}
		
		for(int i = dig_start; i >= 1; i--){
			for(int j = 9; j >= 0; j--){
				if(n >= sum[i][j]){
					cout << j;
					n -= sum[i][j];
					break;
				}
				if(j == 0){
					cout << 0;
				}
			}
		}
		cout << endl;
		
	}
	
	return 0;
}

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

using namespace std;


int main(){
    long ans=0;
    int c=0;
    int n;
    while(cin>>n){
        ans+=n%8*pow(10,c);
        n/=8;
        if(n==0)break;
        c++;
    }
    for(int i=0;i<=c;i++){
        int temp=((long)(ans/pow(10,i))%10);
        if(temp==4)ans+=pow(10,i);
        if(temp>=5)ans+=2*pow(10,i);
    }
    cout<<ans<<endl;
    
    return 0;
}

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

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 <iostream>

using namespace std;

int main(void){

  int num[] = {0,1,2,3,5,7,8,9};
  int n;
  long long a = 0;
  long long b = 1;

  while( cin >> n , n ){
    
    while(n){
      a += num[n % 8] * b;
      b *= 10;
      n /= 8;
    }
cout << a << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long int lli;

string str = "01235789";

void func(lli n)
{
  if(n == 0) return;
  func(n/8);
  cout << str[n%8];
}

int main()
{
  lli n;

  while(cin>>n && n){
    func(n);
    cout << endl;
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n; while(cin>>n,n){
		int d[99]={0},c=0;
		while(n>0){
			d[c++]=n%8;
			n/=8;
		}
		while(c--)cout<<"01235789"[d[c]];cout<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main()
{
  const char tbl[] = { '0','1','2','3','5','7','8','9' };
  for(;;){
    long long n;
    cin >> n;
    if(n==0) break;
    char buf[20];
    sprintf(buf,"%o",n);
    for(int i=0; i<20; i++){
      if(buf[i] == '\0') break;
      buf[i] = tbl[buf[i] - '0'];
    }
    cout << buf << endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
typedef long long ll;
int main( void )
{
  ll a;
  while( 1 ){
    cin >> a;
    if( !a ) break;
    ll ret = 0;
    ll scale = 1;
    while( a > 0 ){
      ll d = a & 7;
      a = a >> 3;
      if( d >= 4 ) d++;
      if( d >= 6 ) d++;
      ret += d * scale;
      scale *= 10;
    }
    cout << ret << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    string s = "01235789";
    while(cin >> n, n){
        string ans;
        while(n){
            ans += s[n%8];
            n /= 8;
        }
        reverse(ans.begin(),ans.end());
        cout << ans << "\n";
    }
    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",buf)
	}
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)


static const string t = "01235789";

string	 to(int n){
	string ans;
	while(n) ans += t[n%8] , n/=8;
	reverse(ans.begin(),ans.end());
	return ans;
}

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

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

using namespace std;

int main(void)
{
	// itoa
	int n;
	while (cin >> n, n){
		char s[20];
		itoa(n, s, 8);
		
		string str = s;
		for (int i = 0; i < str.length(); i++){
			if ('4' <= str[i]) str[i]++;
			if ('6' <= str[i]) str[i]++;
		}
		cout << str << endl;
	}
	
	return 0;
}