Jump to content

Count in base 27


Recommended Posts

I am trying to make a script which generates all the possible letter combinations to a certain length. Is there anyway to count in base 27, by this I mean

for($a=1; a<10000; a+=1)
if ($a=1) {


It would then enter the string into a database.

It would count like this http://www.thecrimelife.com/files/example.txt NOTE: I typed this up.

Any help would be appreciated.

Link to comment
Share on other sites

Re: Count in base 27


$a = 85;
$b = 24;
echo "

Original value of \$a is $a and \$b is

$c = $a % $b;
echo "

The modulus of \$a and \$b is $c</P>";



then read http://en.wikipedia.org/wiki/Modulo_operation

and http://en.wikipedia.org/wiki/Base_%28mathematics%29

basically what you want to do is find the remainder (modulus) of the number you have, and the base you want it in.

So for example, if you want to express "43" in base 8:

first divide 43 by 8 = 5 point something

then find the remainder with 43 mod 8 = 3

so 43 in base 8 would be 5*8 + 3

sort of like how 43 in base 10 is 4*10 + remainder (3)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...