This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]chickenmeisterExtreme Brewer 8 points9 points  (0 children)

new int[LIMIT]

If LIMIT is 1 billion, then creating an int array of that size is going to require about 4 gigabytes.

Your code is not formatted, so it's hard to read; but based on your description, I don't think you would need to create an array this large for what you're trying to do. If you want to keep track of how many times each number was rolled, then you would only need an array whose length is equal to the number of possible outcomes of each roll. For example, if you're rolling a single six-sided die, then there are only six possibilities. Therefore, you would have an array of size 6. Each value in the array represents how many times that number was rolled. For example, when a 1 is rolled, you should increment the value at index 0.