Print All Binary
Print All Binary from 0 to n-1
e.g. Given 10, print all binary number from 0 to 10-1
/**
* print all binary from zero to num-1 with length log2(num)
* @param num maximum number
*/
public static void printAllBinary(int num) {
String str = "";
int binLen = (int)Math.ceil(Math.log(num)/Math.log(2));

for(int j=0; j<num; j++){
int n = j;
for(int i=0; i<binLen; i++){
if(n % 2 == 0)
str = "0" + str;
else
str = "1" + str;

n = n/2;
}
Print.plb(str);
str = "";
}
}

e.g. Given 10, output:
A->1
B->2
C->3
D->4
E->5
F->6
G->7
H->8
I->9
G->10
// [1 -> 26] = ['A' -> 'Z']
// [0 -> 25]   ['A' -> 'Z']
public static void excelNumSaveLength(int num) {
int binLen = 1;
if(num == 1)
binLen = 1;
else
binLen = (int)Math.ceil(Math.log(num)/Math.log(26));

for(int j=1; j<=num; j++){
int n = j;
String str = "";
for(int i=1; i<=binLen; i++){
String s = Aron.intToAlphabetUpper((n-1)%26);
str = s + str;
n = (n-1)/26;
}
Print.plb(str);
}
}

Print all Excel Header Number from A to ...
// [1 -> 26] = ['A' -> 'Z']
// [0 -> 25]   ['A' -> 'Z']
public static void printExcel(int num){
int base = 26;
for(int i=1; i<=num; i++){
int x = i;
String str = "";
if(x-1 == 0)
str = 'A' + str;
else{
while( x > 0){
int r = (x-1) % base;
String s = Aron.intToAlphabetUpper(r);
str = s + str;
x = (x-1) / base;
}
}
Print.plb(str);
}
}