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>
#include <map>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

typedef long long ll;


int fourOrSixPlace(ll num){
	int idx=-1;
	int cnt=0;
	while(num>0){
		if(num%10==6||num%10==4){
			idx=cnt;
		}
		num/=10;
		cnt++;
	}
	return idx;
}

int main(){

	//int cc=0;
	//for(ll i = 1; i <= 1000000; i++){
	//	int ret=fourOrSixPlace(i);
	//	if(ret!=-1)
	//		cc++;
	//}
	//cout<<cc<<endl;



	ll n;
	while(cin>>n&&n!=0){
		ll cnum=0;
		ll cnt=0;
		while(1){
			cnum+=1000000;
			if(cnum>n)
				break;
			int ret=fourOrSixPlace(cnum);
			if(ret==-1){
				//				cnt+=32769;
				n+=737856;
			}
			else{
				n+=737856;
				cnum+=(ll)pow(10.0,ret);
				n+=(ll)pow(10.0,ret);
			}
		}
		if(cnum==n){
			cout<<n<<endl;
		}
		else{
			cnum-=1000000;
			cnum++;
			for(ll i = cnum; i <= n; i++){
				int ret=fourOrSixPlace(i);
				if(ret!=-1){
					if(ret==0){
						n++;
					}
					else{
						n+=(ll)pow(10.0,ret);
						i+=(ll)pow(10.0,ret);
					}
				}
			}
		}


		//int cnt=0;
		cout<<n<<endl;
	}

	//ll n;
	//while(cin>>n&&n!=0){

	//}

	return 0;
}

C++: #include<iostream>
using namespace std;
int ans[100];
int esc[8]={0,1,2,3,5,7,8,9};
int main(){
	int n;
	while(true){
	cin>>n;
	if(n==0)break;
	int top=0;
	while(true){
		ans[top]=n%8;
		n/=8;
		if(n==0)break;
		top++;
	}
	for(int i=top;i>=0;i--)cout<<esc[ans[i]];
	cout<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int main()
{
	for(;;){
		int n;
		vector<int>a;
		scanf("%d",&n);
		if(n==0)return 0;

		while(n!=0){
			a.push_back(n%8);
			n/=8;
		}

		for(int i=a.size()-1;i>=0;i--){
			if(a[i]<=3)printf("%d",a[i]);
			if(a[i]==4)printf("%d",a[i]+1);
			if(a[i]>=5)printf("%d",a[i]+2);
		}
		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\n",s);
}
}

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

using namespace std;

int TableNewOctal[] = { 0,1,2,3,5,7,8,9 };
vector<int> Result;

int main() {
	int num;

	while (cin >> num, num) {
		while (num > 0) {
			Result.push_back(TableNewOctal[num % 8]);
			num /= 8;
		}
		while (!Result.empty()) {
			cout << Result.back();
			Result.pop_back();
		}
		cout << endl;
	}

	return 0;
}

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

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

}

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

using namespace std;

int MAX_N = 1000000000;

void hex(vector<int> *c, int num);

int main(int argc, char** argv)
{
	int n, d;
	vector<int> v;
	while( 1 )
	{
		v.clear();
		cin >> n;
		if(n==0) break;

		hex(&v, n);
		for(int i=0; i<v.size(); i++){
			d = v[v.size() - i - 1];
			if(d>=4) d++;
			if(d>=6) d++;
			cout << d;
		}
		cout << endl;
	}
}

void hex(vector<int> *c, int num)
{
	int count = 0;
	while(num != 0)
	{
		c->push_back(num % 8);
		num /= 8;
	}
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int ng(int n){
	string s=toString(n);
	int len=s.size();
	REP(i,len){
		if(s[i]=='4'||s[i]=='6'){
			return pow((double)10,len-i-1);
		}
	}
	return 0;
}

int main(){
	int n;
	while(cin>>n,n){
		int ans=0;
		FOR(i,1,n+1){
			ans++;
			ans+=ng(ans);
		}
		cout<<ans<<endl;
	}
}

C++: #include<stdio.h>
int main(){
  int i;
  char s[10];
  while(scanf("%d",&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);
}
}

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

int main()
{
  int n;
  while (cin >> n && n != 0) {
    ostringstream oss;
    oss << oct << n;
    string s = oss.str();
    for (string::iterator it(s.begin()); it != s.end(); ++it) {
      static const char tbl[] = "01235789";
      *it = tbl[*it-'0'];
    }
    cout << s << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

typedef long long ll;

int cnv(int n){
	if(n<=3)
		return n;
	else{
		if(n==4)
			return 5;
		else
			return n+2;
	}
}

void dfs(int num){
	if(num==0)
		return;
	dfs(num/8);
	cout<<cnv(num%8);
}

int main(){

	int n;
	while(cin>>n&&n!=0){
		dfs(n);
		cout<<endl;
	}


	return 0;
}


//int fourOrSixPlace(ll num){
//	int idx=-1;
//	int cnt=0;
//	while(num>0){
//		if(num%10==6||num%10==4){
//			idx=cnt;
//		}
//		num/=10;
//		cnt++;
//	}
//	return idx;
//}
//
//int main(){
//
//	//int cc=0;
//	//for(ll i = 1; i <= 100000; i++){
//	//	int ret=fourOrSixPlace(i);
//	//	if(ret!=-1)
//	//		cc++;
//	//}
//	//cout<<cc<<endl;
//	ll n;
//	while(cin>>n&&n!=0){
//		ll cnum=0;
//		ll cnt=0;
//		while(1){
//
//			cnum+=100000;
//			if(cnum>n)
//				break;
//			int ret=fourOrSixPlace(cnum);
//			if(ret==-1){
//				n+=67232;
//			}
//			else{
//				n+=67232;
//				cnum+=(ll)pow(10.0,ret);
//				n+=(ll)pow(10.0,ret);
//			}
//		}
//
//		if(true){
//			cnum-=100000;
//			cnum++;
//
//			for(ll i = cnum; i <= n; i++){
//				int ret=fourOrSixPlace(i);
//				if(ret!=-1){
//					if(ret==0){
//						n++;
//					}
//					else{
//						n+=(ll)pow(10.0,ret);
//						i+=(ll)pow(10.0,ret);
//					}
//				}
//			}
//		}
//		cout<<n<<endl;
//	}
//
//
//	return 0;
//}

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

int c[8] = {0, 1, 2, 3, 5, 7, 8, 9};
void solve(int n) {
  if(n >= 8) solve(n / 8);
  cout << c[n % 8] << endl;
}
int main() {
  int n;
  while(cin >> n, n) {
	solve(n);
  }
  return 0;
}

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 % 8 == 4) no++;
      else if(no % 8 >= 5) no+=2;
      cout << no;
      sum.pop();
    }
    cout << endl;
  }
  return 0;
}