actually, the program runs perfectly, its just for computing a maximum value before i get a memory error.
basically what the program does, is take a number, and compute all of the primes beneath that number, and write them to a file. dividing by every number, ie 1,2,3,4,5,etc, is redundant because dividing by 4 is alread covered by dividing by 2 etc., and in truth, you only need to divide by a list of already computed primes. so i have an array created in which to store the primes. the approximate distribution of primes at a given number is one prime ever ln(x) numbers. so to compute how many primes there should be in theory, i used ln(x/3), which gives about .1% error (for example between 1 and 50,000 there are 5133 primes, and 50,000/ln(50,000/3) gives 5143). so i created an array which has x/ln(x/3) values in it to maximize memory use. but to save even more memory, i realized that the only primes less than the sqrt of your highest number would have to be stored in the array. so for example if you were computing primes between 1 and 50,000, it doesnt matter that 49,999 is a prime for the array, because you would never have to divide 50,000 by 49,999 because it's parallel on the other side of the sqrt of 50,000 has already been tested. so instead, i creadted an array with sqrt(x)/ln(sqrt(x)/3) places in it, where x is the highest number, in this case 50,000. from my personal experience, i know that i can create an array of about 15,000,000 without having a memory error. so the maximum highest number i can compute to is defined by the equation 15,000,000=sqrt(x)/ln(sqrt(x)/3). from multiple runs of the program, i dont get a memory error until i input values in the range of 75-80 quadrillion, leading me to belive that the value of x that i'm looking for is in that range. unless that is, i had some huge lapse of logic which i'm missing.