I feel dumb by asking this question.

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

I feel dumb by asking this question.

Post 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 =[
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

37 to the power of 25 = 1,603,404,513,114,153,724,313,506,335,083,015,711,557
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Yeah, so assume the number is > than that.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

It's safe to assume there are more combinations than grains of sand on the earth.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post 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: :) )
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

I think it is 38 to the power of 25. 37 + blank.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post 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.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Yeah you're right. Only just woke up when I said that.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Sounds like somebody is trying to develop a brute force algorithm :P
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post 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
Last edited by Oren on Sat Jun 23, 2007 5:31 pm, edited 1 time in total.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

I'll leave that to you Oren :wink:
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post 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
Post Reply