Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#Java 7, 81 bytes

Java 7, 81 bytes

int i=0;String c(int n){return i<n?c(n-++i):Long.toString(i,36)+(n>(i=0)?c(n):"");}

Port from @Arnauld's amazing JavaScript (ES6) answer.
My own approach was almost 2x as long..

Try it here.

Explanation:

int i=0; // Temp integer `i` (on class level)
String c(int n){ // Method with integer parameter and String return-type
 return i<n? // If `i` is smaller than the input integer
 c(n-++i) // Return a recursive call with input minus `i+1` (and raise `i` by 1 in the process)
 : // Else:
 Long.toString(i,36)+ // Return `i` as Base-36 +
 (n>(i=0)? // (If the input integer is larger than 0 (and reset `i` to 0 in the process)
 c(n) // Recursive call with the input integer
 : // Else:
 ""); // an empty String)
} // End of method

#Java 7, 81 bytes

int i=0;String c(int n){return i<n?c(n-++i):Long.toString(i,36)+(n>(i=0)?c(n):"");}

Port from @Arnauld's amazing JavaScript (ES6) answer.
My own approach was almost 2x as long..

Try it here.

Explanation:

int i=0; // Temp integer `i` (on class level)
String c(int n){ // Method with integer parameter and String return-type
 return i<n? // If `i` is smaller than the input integer
 c(n-++i) // Return a recursive call with input minus `i+1` (and raise `i` by 1 in the process)
 : // Else:
 Long.toString(i,36)+ // Return `i` as Base-36 +
 (n>(i=0)? // (If the input integer is larger than 0 (and reset `i` to 0 in the process)
 c(n) // Recursive call with the input integer
 : // Else:
 ""); // an empty String)
} // End of method

Java 7, 81 bytes

int i=0;String c(int n){return i<n?c(n-++i):Long.toString(i,36)+(n>(i=0)?c(n):"");}

Port from @Arnauld's amazing JavaScript (ES6) answer.
My own approach was almost 2x as long..

Try it here.

Explanation:

int i=0; // Temp integer `i` (on class level)
String c(int n){ // Method with integer parameter and String return-type
 return i<n? // If `i` is smaller than the input integer
 c(n-++i) // Return a recursive call with input minus `i+1` (and raise `i` by 1 in the process)
 : // Else:
 Long.toString(i,36)+ // Return `i` as Base-36 +
 (n>(i=0)? // (If the input integer is larger than 0 (and reset `i` to 0 in the process)
 c(n) // Recursive call with the input integer
 : // Else:
 ""); // an empty String)
} // End of method
added 773 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

#Java 7, 81 bytes

int i=0;String c(int n){return i<n?c(n-++i):Long.toString(i,36)+(n>(i=0)?c(n):"");}

Port from @Arnauld's amazing JavaScript (ES6) answer.
My own approach was almost 2x as long..

Try it here.

Explanation:

int i=0; // Temp integer `i` (on class level)
String c(int n){ // Method with integer parameter and String return-type
 return i<n? // If `i` is smaller than the input integer
 c(n-++i) // Return a recursive call with input minus `i+1` (and raise `i` by 1 in the process)
 : // Else:
 Long.toString(i,36)+ // Return `i` as Base-36 +
 (n>(i=0)? // (If the input integer is larger than 0 (and reset `i` to 0 in the process)
 c(n) // Recursive call with the input integer
 : // Else:
 ""); // an empty String)
} // End of method

#Java 7, 81 bytes

int i=0;String c(int n){return i<n?c(n-++i):Long.toString(i,36)+(n>(i=0)?c(n):"");}

Port from @Arnauld's amazing JavaScript (ES6) answer.
My own approach was almost 2x as long..

Try it here.

#Java 7, 81 bytes

int i=0;String c(int n){return i<n?c(n-++i):Long.toString(i,36)+(n>(i=0)?c(n):"");}

Port from @Arnauld's amazing JavaScript (ES6) answer.
My own approach was almost 2x as long..

Try it here.

Explanation:

int i=0; // Temp integer `i` (on class level)
String c(int n){ // Method with integer parameter and String return-type
 return i<n? // If `i` is smaller than the input integer
 c(n-++i) // Return a recursive call with input minus `i+1` (and raise `i` by 1 in the process)
 : // Else:
 Long.toString(i,36)+ // Return `i` as Base-36 +
 (n>(i=0)? // (If the input integer is larger than 0 (and reset `i` to 0 in the process)
 c(n) // Recursive call with the input integer
 : // Else:
 ""); // an empty String)
} // End of method
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

#Java 7, 81 bytes

int i=0;String c(int n){return i<n?c(n-++i):Long.toString(i,36)+(n>(i=0)?c(n):"");}

Port from @Arnauld's amazing JavaScript (ES6) answer.
My own approach was almost 2x as long..

Try it here.

AltStyle によって変換されたページ (->オリジナル) /