Page 1 of 2

I feel dumb by asking this question.

Posted: Fri Jun 22, 2007 11:39 pm
by s.dot
I wanted to find the number of permutations with repitition using the numbers a-z, letters, 0-9, and underscores (which gives a total of 37 characters) for a screenname that can be 1-25 characters long. So I came up with this coding:

Code: Select all

C:\Users\HP_Administrator>php -r "$n = 37; $s = array(); for($r=1;$r<26;$r++){ $
s[] = pow($n, $r); } $s = array_sum($s);  echo $s;"
1.6479435273673E+039
What is 1.6479435273673E+039 if you evaluate the E+039 =[

Posted: Fri Jun 22, 2007 11:45 pm
by Benjamin
37 to the power of 25 = 1,603,404,513,114,153,724,313,506,335,083,015,711,557

Posted: Fri Jun 22, 2007 11:48 pm
by s.dot
But that's if you only used screennames that were 25 characters in length. Screennames can be between 1 and 25 characters in length, which is why i stuck it in a for() loop. Correct?

Posted: Fri Jun 22, 2007 11:53 pm
by s.dot
I think I just move the decimal point to the right 39 places. :lol:

and get, 1,647,943,527,367,300,000,000,000,000,000,000,000,000

Posted: Fri Jun 22, 2007 11:54 pm
by Benjamin
Yeah, so assume the number is > than that.

Posted: Fri Jun 22, 2007 11:58 pm
by s.dot
Cool. There was just a discussion about this on another forum, and I had to be the smarty and figure out the possible number of combinations.

Posted: Sat Jun 23, 2007 12:22 am
by Benjamin
It's safe to assume there are more combinations than grains of sand on the earth.

Posted: Sat Jun 23, 2007 3:07 am
by Luke
I'm going to move this thread to "miscellaneous". This section is not for code discussion (although I must admit. I forget that often as well :oops: :) )

Posted: Sat Jun 23, 2007 3:37 am
by Ollie Saunders
I think it is 38 to the power of 25. 37 + blank.

Posted: Sat Jun 23, 2007 10:22 am
by Benjamin
ole wrote:I think it is 38 to the power of 25. 37 + blank.
That would allow for characters after the first blank character and hence would be > than the actual combinations.

Posted: Sat Jun 23, 2007 12:59 pm
by Ollie Saunders
Yeah you're right. Only just woke up when I said that.

Posted: Sat Jun 23, 2007 1:32 pm
by alex.barylski
Sounds like somebody is trying to develop a brute force algorithm :P

Posted: Sat Jun 23, 2007 4:01 pm
by Oren
Compute this:

Σpow(37, i) - where i runs from 1 to 25

Which is a finite geometric series, therfore: # of possible names = (a1*(1 - q^n)) / (1 - q) = (37*(1 - 37^25)) / (1 - 37) = (37 - 37^26) / -36

Posted: Sat Jun 23, 2007 5:04 pm
by Benjamin
I'll leave that to you Oren :wink:

Posted: Sat Jun 23, 2007 5:06 pm
by Oren
Oh man... it's after 1AM now and I made so many mistakes... I had already edited the previous post so many times before. I just hope I didn't make a mistake this time, as I said... it's after 1AM :P