
-----------------------------------
pileggi
Thu Oct 12, 2006 7:25 am

Number List, having trouble!!
-----------------------------------
Hi
I'm trying to make a number list, going from
000000000
to
999999999

we're learning encryption in school, so we need to make a number list from 0 to a billion, but keeping the rest of the places filled with "0"

ex

000000001
000000002

etc.

(yes I realize this will make an incredibly large file, and my system will be dead for a while, I'm working on that)

i ran it this morning using Ready to Program Dr Java, run with args, print to file.. made a 160MB text file in like 15 mins.  

So I need to figure out a way to code it in that it will write to a file, and change the file it writes to every hundred thousand numbers or something.. (I don't know how to write to files.. :-s we don't learn that)

Also, if you run my code, you'll notice the formatting goes off between 100, to 110.

And then later on from 10000 to 11000

there is an extra zero.. and probably every subsequent multiple of ten or something.. I don't know



Do you guys think it would be easier to create an array of 10 across, down by 1 billion. Initialize everything to zero, then just store numbers starting from the right side, into the array (using mod + div to break the numbers down into individual digits)

0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 2
0 0 0 0 0 0 0 0 3

etc.

And then print the array to a file?

Is it even possible to make an array of one billion? How can I get around this  :-s




class testpass
{
  
  public static void main (String [] args)
  {
    int x=0;
       
    for(int i2=0;i2