- public static void main(String[] args) {
- for (int i = 0; i < 3000; i++) {
- System.out.println(""+i+":"+three(i));
- }
- }
- public static String three(int n) {
- StringBuffer sb = new StringBuffer();
- int n1 = 1;
- sb.append("" + n % 3);
- while ((n1 = (n / 3)) != 0) {
- n = n1;
- sb.append("" + n % 3);
- }
- return sb.reverse().toString();
- }
复制代码
|
|