fork(3) download
  1. /* package whatever; // don't place package name! */
  2.  
  3.  
  4. class Main{
  5. public static void main(String[] a){
  6. System.out.println("2: " + c(2));
  7. System.out.println("8: " + c(8));
  8. System.out.println("12: " + c(12));
  9. System.out.println("16: " + c(16));
  10. System.out.println("18: " + c(18));
  11. System.out.println("24: " + c(24));
  12. System.out.println("32: " + c(32));
  13. }
  14.  
  15. static String c(int n) {
  16. return "" +
  17. (n > 9
  18. ? (n % 9) + s(n)
  19. : n + 9);
  20. }
  21.  
  22. static String s(int n) {
  23. String s = "";
  24. for (int i = 0; i < (n / 9); i++) {
  25. s += "9";
  26. }
  27. return s;
  28. }
  29. }
Success #stdin #stdout 0.1s 320512KB
stdin
Standard input is empty
stdout
2: 11
8: 17
12: 39
16: 79
18: 099
24: 699
32: 5999