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(){
/*(^(^(^(^(^o^)^)^)^)^) &#9602;&#9605;&#9607;&#9608;&#9619;&#9618;&#9617;('ω')&#9617;&#9618;&#9619;&#9608;&#9607;&#9605;&#9602; */
	  int m;
	  while(scanf("%d",&m)){
		  if(m==0) break;
		  int n[100],b=0,i;
		  while(m>=8){
			  n[b]=m%8;
			  m /= 8;
		      b++;
		  }
		  n[b]=m;
		  for(i=0;i<=b;i++){
			  if(n[i]==4){
				  n[i]=5;
			      continue;
			  }
			  if(n[i]==5){
				  n[i]=7;
			      continue;
			  }if(n[i]==6){
				  n[i]=8;
			      continue;
			  }
			  if(n[i]==7){
				  n[i]=9;
			      continue;
			  }}
		  for(i=b;i>=0;i--){
			  printf("%d",n[i]);
		  }
		  printf("\n");
	  }
		  return 0;
	  }

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

int main(){
  int x;

  while(cin >> x, x){
    string ans = "";

    while(x != 0){
      int rem = x % 8;
      x /= 8;

      int d;

      if(rem < 4){
        d = rem;
      }
      else if(rem < 5){
        d = rem + 1;
      }
      else{
        d = rem + 2;
      }

      ans = (char)('0' + d) + ans;
    }

    cout << ans << endl;
  }
}

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

unsigned int dec_to_oct(unsigned int num)
{
  int result = 0;
  for (int i = 1; num != 0; i *= 10)
  {
    result += (num % 8) * i;
    num = num / 8;
  }
  return result;
}

int main(void)
{
  unsigned int room_num;
  unsigned int buf;
  unsigned int new_room_num;
  int num_table[8] = { 0, 1, 2, 3, 5, 7, 8, 9, };
  
  while (true)
  {
    cin >> room_num;
    if ( room_num == 0 ) break;
    buf = dec_to_oct(room_num);

    new_room_num = 0;
    for (int i = 1; buf != 0; i *= 10)
    {
      new_room_num += num_table[(buf % 10)] * i;
      buf /= 10;
    }

    cout << new_room_num << endl;
  }
  return 0;
}

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 <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;
typedef pair<int,int> P;
const int INF = 1<<29;

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

int main(){
    while(1){
        int n;
        scanf("%d",&n);
        if(!n)break;

        vector<int> ans;
        while(n){
            int a = n&7;
            ans.push_back(eight[a]);
            n >>= 3;
        }
        for(int i=ans.size()-1;i>=0;i--){
            printf("%d",ans[i]);
        }
        printf("\n");
    }

    return 0;
}

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

unsigned long int dec_to_oct(unsigned long int num)
{
  unsigned long int result = 0;
  for (int i = 1; num != 0; i *= 10)
  {
    result += (num % 8) * i;
    num = num / 8;
  }
  return result;
}

int main(void)
{
  unsigned long int room_num;
  unsigned long int buf;
  unsigned long int new_room_num;
  unsigned long int num_table[8] = { 0, 1, 2, 3, 5, 7, 8, 9, };
  
  while (true)
  {
    cin >> room_num;
    if ( room_num == 0 ) break;
    buf = dec_to_oct(room_num);

    new_room_num = 0;
    for (int i = 1; buf != 0; i *= 10)
    {
      new_room_num += num_table[(buf % 10)] * i;
      buf /= 10;
    }

    cout << new_room_num << endl;
  }
  return 0;
}

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

int main(){
    int in_num;
    char num_s8[12];
    cin  >> in_num;
    snprintf(num_s8, sizeof(num_s8), "%o", in_num);
    printf("%s\n", num_s8);

    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 <string>
#include <vector>
using namespace std;

void convert(int x, vector<int> *v) {
  if(x == 0) return;
  convert(x / 8, v);
  v->push_back(x % 8);
}

int main() {
  while(1) {
    int n;
    cin >> n;
    if(n == 0) break;

    vector<int> v;
    convert(n, &v);
    for(int i = 0; i < v.size(); i++) {
      int temp = v[i];
      if(temp >= 4) temp++;
      if(temp >= 6) temp++;
      cout << temp;
    }
    cout << endl;
  }
  return 0;
}

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

using namespace std;

int main() {

	long long int n, r;
	string s="";
	char x[sizeof(int)];

	while(cin >> n) {
		if(!n)
			break;
		r=0;
		
		for(int i=0; i<n; i++) {
			while(1) {
				r++;
				sprintf(x, "%d", r);
				if(!(strchr(x, '4')!=NULL)&&!(strchr(x, '6')!=NULL))
					break;
			}
		}
		cout << x << endl;
	}

	return 0;

}

C++: #include<iostream>

int n;
int pw[10] = {1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000};

void solve(){
	int ans = 0;
	int tmp = n;
	for(int i=0; i<10; i++){
		int temp = tmp%8;
		if(temp==4)
			temp++;
		else if(temp > 4)
			temp+=2;
		if(i==9)
			std::cout << temp;
		else{
			ans += temp*pw[i];
			tmp = tmp/8;
			if(tmp == 0)
				break;
		}
	}
	std::cout << ans << std::endl;
}

int main(){
	while(true){
		std::cin >> n;
		if(!n)
			return 0;
		solve();
	}
}

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

int getValue(int x){
	if(x <= 3)
		return x;
	else if(x == 4)
		return 5;
	else
		return x + 2;
	
		
}
int main() {
	long long n;
	while(cin >> n && n){
		int ans[100] = {0}, c = 0;
		while(n > 0){
			ans[c++] = getValue(n % 8);
			n /= 8;
		}
		for(int i = c - 1; i >= 0; --i)
			cout << ans[i];
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
	int n, num[100];
	while (cin >> n, n) {
		int k = -1;
		do {
			num[++k] = n % 8;
			if (num[k] >= 5) num[k] += 2;
			else if (num[k] >= 4) ++num[k];
		} while (n /= 8);
		for (int i = k; i >= 0; --i) cout << num[i];
		cout << endl;
	}
	return 1;
}

C++: #include <iostream>

using namespace std;

int main(){
  char 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;
      //      cout << output_num << " " ;
      count_num++;
    }
    for(int j=count_num;j>0;j--){
      output_num[j-1] += output_num[j] * 10;
      //      cout << output_num[j] << " ";
    }

    cout << output_num[0];
    cout << endl;
  }

}

C++: #include<iostream>
int main(){
	while(1){
		int a;
		std::cin>>a;
		double int b=1;
		if(a==0)break;
		for(int i=0;i<a;i++){
			b++;
			int n=10;
			for(int j=0;j<10;j++){
				while(a%n==4||a%6==&||a/n==4||a/n==6){
					b++;
				}
			}
		}
		std::cout<<b<<std::endl;
	}
			
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define clear(v) memset(v,0,sizeof(v))

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

void oct(int n){
	if (n >= 8){
		oct(n / 8);
	}
	cout << table[n % 8];
}

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