package com.company;
public class Solution {
static public void main(String[] args) {
System.out.println(solution(1).equals("1") );
System.out.println(solution(2).equals("2") );
System.out.println(solution(3).equals("4") );
System.out.println(solution(4).equals("11") );
System.out.println(solution(5).equals("12") );
System.out.println(solution(6).equals("14") );
System.out.println(solution(7).equals("21") );
System.out.println(solution(8).equals("22") );
System.out.println(solution(9).equals("24") );
System.out.println(solution(10).equals("41") );
}
static int DIV_VALUE = 3;
static public String solution(int n) {
String answer = "";
answer = solveWithRecursive(n);
return answer;
}
static public String solveWithRecursive(int n) {
if(n == 0)
return "";
int[] strangeCounturyNumberArray = {4,1,2};
int div = n / DIV_VALUE;
int mod = n % DIV_VALUE;
if (div == 0) {
return String.valueOf(strangeCounturyNumberArray[mod]);
}
else {
if(mod == 0)
div -= 1;
return solveWithRecursive(div) + strangeCounturyNumberArray[mod];
}
}
}