Will Posted June 7, 2007 Posted June 7, 2007 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) { $b='a' } etc.. 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. Quote
monbster Posted June 8, 2007 Posted June 8, 2007 Re: Count in base 27 to count in different bases learn how to use the modulus operator http://us2.php.net/operators.arithmetic Quote
Will Posted June 8, 2007 Author Posted June 8, 2007 Re: Count in base 27 Any example of a code how to do this? Quote
monbster Posted June 9, 2007 Posted June 9, 2007 Re: Count in base 27 <? $a = 85; $b = 24; echo " Original value of \$a is $a and \$b is $b</P>"; $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) Quote
Will Posted June 10, 2007 Author Posted June 10, 2007 Re: Count in base 27 Ah. I think I get it now. :-D Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.