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() {
	long long ans;
	int i,k,n,o[10];
	for (i=1,o[0]=1;i<10;i++) o[i]=o[i-1]*8;
	while(cin >> n && n>0) {
	ans=0;	
	for (i=9;i>=0;i--) {
		if (n>=o[i]) { k=n / o[i]; n=n % o[i];
		               if (k==4) k=5; else  if (k>4) k+=2;
		               ans+=k;
		                }
		if (i>0) ans=ans*10;
		}
	cout << ans << endl; 		   
}

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

using namespace std;

string toOct(long long  d)
{
	char c[30];
	string s = "";
	
	sprintf(c, "%o", d);
	s += c;

	return s;
}


string solve(long long  n)
{
	char c[30];
	string s;

	s = toOct(n);

	for( int i = 0; i < (int)s.length(); i++)
	{
		if( s[i] >= '4' )
			s[i] += '1' - '0';

		if( s[i] >= '6' )
			s[i] += '1' - '0';
	}

	return s;
}


int main()
{
	long long n;

	while( cin >> n, n)
	{
		cout << solve(n) << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
int main(){
  long long n;
  while(cin>>n&&n){
    string ans="";
    while(n>0){
      ans+=n%8+'0';
      n/=8;
    }
    for(int i=ans.size()-1;i>=0;i--){
      if(ans[i]>='4')ans[i]++;
      if(ans[i]>='6')ans[i]++;
      cout<<ans[i];
    }
    cout<<endl;
  }
}

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

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

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



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

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

//対応表

//8進数変換
void eight(int n){
	int table[] = {0,1,2,3,5,7,8,9};
	if(n >= 8){
		eight(n / 8);
	}
	cout << table[n % 8];
}

int main(){
	int num;
	while(cin >> num,num){
		eight(num);
		cout << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  char s[20];
  while(cin>>n,n){
    sprintf(s,"%o",n);
    for(int i=0;i<strlen(s);i++){
      if(s[i]>='4')s[i]++; 
      if(s[i]>='6')s[i]++; 
    }
  }cout<<s<<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",ans);
}
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

//n??????
//Radix r;
//cout << r.to(n, 4) << endl;
class Radix {
private:
	const char* s;
	int a[128];
public:
	Radix(const char* s = "0123456789ABCDEF") : s(s) {
		for (int i = 0; s[i]; i++) a[(int)s[i]] = i;
	}
	string to(long long p, int q) {
		if (!p) return "0";
		char t[64] = {};
		int i;
		for (i = 62; p; i--) {
			t[i] = s[p % q];
			p /= q;
		}
		return string(t + i + 1);
	}
	string to(const string &t, int p, int q) {
		return to(to(t, p), q);
	}
	long long to(const string &t, int p) {
		long long sm = a[(int)t[0]];
		for (int i = 1; i < (int)t.length(); i++)
			sm = sm * p + a[(int)t[i]];
		return sm;
	}
};

signed main() {
	for (int n; cin >> n&&n;) {
		Radix r("01235789");
		cout << r.to(n, 8) << endl;
	}
	return 0;
}

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

using namespace std;
//char a[10000000000]={};
char b[1000000000]={};
char c[100000000]={};
char d[10000000]={};
char e[1000000]={};

long long int number(long long int n){
  long long int h=0;
  long long int p=0;
  
  while(p<n){
    h++;
    if(h>=1000000000){
      if(b[h%1000000000]==1 || h/1000000000==4 || h/1000000000==6)
	p++;
    }
    else{
      if(b[h]==1)
	p++;
    }
  }
  return h;
}
  


int main() {
    ios::sync_with_stdio(false);
    long long int s;
    int m=1;
    while(m<=999999){
      int t=m;
      while(t>0){
	if(t%10==4 || t%10==6)
	  {e[m]--;break;}
	else{
	  t=t/10;      
	}
      }
      d[m]++;
      m++;
    }
    
    int p,q;
    for(p=0;p<1000000;p++){
      for(q=0;q<9;q++){
	if(q!=4 || q!=6)
	  d[q*1000000+p]+=e[p];
      }
    }


    for(p=0;p<10000000;p++){
      for(q=0;q<9;q++){
	if(q!=4 || q!=6)
	  c[q*10000000+p]+=d[p];
      }
    }
    
    for(p=0;p<100000000;p++){
      for(q=0;q<9;q++){
	if(q!=4 || q!=6)
	  b[q*100000000+p]+=c[p];
      }
    }

    /*
    for(p=0;p<1000000000;p++){
      for(q=0;q<9;q++){
	if(q!=4 || q!=6)
	  a[q*1000000000+p]+=b[p];
      }
    }
    */
    
    while (1) {
      cin >> s;
      if(s != 0){
	cout << number(s) << endl;
      }
      else
	break;
    }

    return 0;
}

C++: #include <stdio.h>

int main()
{
	int n,i,c;
	char s[16];
	while(scanf("%d",&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;

int main()
{
	while(1){
		int a, j=0;
		cin >> a;
		if (a == 0)break;
		j = a;
		string s="";
		int b = 0;
		for (b = 1; b * 8 <= a; b *= 8) {}
		for (int c = b; c != 1; c /= 8) {
			int o =a/c;
			switch (a / c) {
			case 0:case 1:case 2:case 3:cout << a / c;  break;
			case 4:cout << 5; break;
			default:cout << a / c + 2; break;
			}
			
			a -= c*o;
		}
			switch (j % 8) {
			case 0:case 1:case 2:case 3:cout << j % 8; break;
			case 4:cout << 5; break;
			default:cout << j % 8 + 2;
			}
		
		cout << endl;
			}
}

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

int main(){  
	while(true){     
		int n;
		int i=0;
		int x[256],y;
		cin >> n;
		if(n==0)         
			break;   

		while(true){
			x[i] = n;
			i++;
			n = n/8;
			if(n==0)
				break;
			
		}
		for(int j=i; j>0; j--){
			y = x[j-1] % 8;
			
			if(y < 4)
				cout << y;
			else if(y == 4)
				cout << y+1;
			else if(y > 4)
				cout << y+2;
		}
		cout << endl;
	}
	return 0;
}

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

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

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

long long int solve(int n){
	long long int s=0;
	for(int i=1 ; n >0; i *= 10 , n /= 8)
		s += (long long int)t[n%8]*i;
	return s;
}
int main(){
    int n;
    
    while( cin >> n , n ){
		cout << solve(n) << endl;
    }
    
}

C++: #include<iostream>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

string solve(int n) {
  if (n == 0) return "";
  int k = n % 8;
  return solve(n / 8) + "01235789"[k];
}

int main() {
  int n;
  while (true) {
    cin >> n;
    if (n == 0) break;
    cout << solve(n) << endl;
  }
  return 0;
}