java - A simple algorithm to find value from sequence for a Random number? -


this question has answer here:

i create general algorithm sequence (i not storing sequence anywhere).. if

1=a

2=b

3=c

.

.

.

26=z

27=aa

28=ab

29=ac

30=ad

what should code value of random number ? e.g 333

a brilliant example here here ..

function getcharcode(displaynumber){     var orda = 'a'.charcodeat(0);     var ordz = 'z'.charcodeat(0);     var len = ordz - orda + 1;      var returnsequence = "";     while(displaynumber >= 0) {         returnsequence = string.fromcharcode(displaynumber % len + orda) + returnsequence; // (displaynumber % 26 + 65) +""         displaynumber = math.floor(displaynumber / len) - 1; //(displaynumber / 26) - 1     }     return returnsequence; } 

or modified ..

function getcharcode(displaynumber){     var returnsequence = "";     while(displaynumber >= 0) {         returnsequence = string.fromcharcode(displaynumber % 26 + 65) + returnsequence;         displaynumber = math.floor(displaynumber / 26) - 1;     }     return returnsequence; } 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -