Jump to content

for loop => can i generate all possibilities of 10 digits from 0 to 9


Recommended Posts

If you want someone to write code for you, you need to post in the freelance section and be prepared to pay for it.

 

If you have tried and are having problems, post your code and state your problems. We are here to help you figure it out, but not many people here are going to do it for you

 

You do realize that that is 10,000,000,000 (BILLION) individual strings?

 

I got bored, and I took a swing at this for fun. My development server is an old i386 box. For 5 digit numbers -- just to generate them into an array, no printing, no database insert, no file write -- it took 3 minutes to produce the 100,000 values and took up 13 Megabytes of memory. At 6-digits, PHP ran out of memory to hold them. So, I took the array out and started a run for 10-digits. It has been running for 4 hours now, still not done.

 

I'm sure there is a more efficient way to write it. But it is really just one recursive function, so ...

 

What are you going to do with the 10 BILLION names of ... uh, numbers when you get them?

You don't even need a recursive function, one loop is all that's needed. Still, why is an excellent question.

 

m0751n[7b]: This is as basic loop as you can get, and you're being more than just lazy. We're here to help those who put an effort in by themselves, but get stuck for some reason. Not to do our jobs, or yours, for free.

If you want people to provide you with completed code, then the Freelance section is the correct place to post it. That said, freelancers generally expect to get paid for their time and service.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.