function to convert num to base 6
function baseconversion ( arr , num , base ) { var i = 0 , rem , j ; if ( num == 0 ) { return 0 ; } while ( num > 0 ) { rem = num % base ; arr [ i ++ ] = rem ; num = parseInt ( num / base ) ; } return i ; }