Mersenne Number Generator #include #include #include #include #include #include long int max_array_size=7500; //the maximum size of the array int screenwidth =75; //standard for most text viewers //try to keep max_array_size a multiple of screenwidth long int n; //the number of the exponent int creation[7500]; //change this number to allow for longer arrays int last_array_number = max_array_size-1; void getnum() { long int input_getnum = 0; cout << "2 to what power?" << endl; cin >> input_getnum; cout << "Selected Number:" << input_getnum << endl; n = input_getnum; } void mersenne_creation() { cout << "Creating Mersenne Number: " << n << endl; creation[last_array_number]=1; cout << "output:" <= 1; x--) { //cout << "Counting down x:" << x << endl; for(y = 0; y<=last_array_number; y++) { creation[y]= 2*creation[y]; //cout << creation[y] << endl; } for(z=last_array_number; z >= 0; z--) { if (creation[z] > 9) { high = floor(creation[z]/10); high2 = creation[z]-(10*high); creation[z]=high2; creation[(z-1)]=creation[(z-1)]+high; } //cout << creation[y] << endl; } } creation[last_array_number]= creation[last_array_number]-1; } print_out() { ofstream outf("prime.txt"); int y; int length = screenwidth -1; outf << "The number inputed is: " << n << endl; outf << "The length of the array is: "<< max_array_size << endl; outf << "The Mersenne Number is:" << endl; for(y = 0; y<=last_array_number; y++) { cout << creation[y]; outf << creation[y]; if(y == length) { length=length+screenwidth; cout << endl; outf << creation[y] << endl; } } outf.close(); } void main(void) { getnum(); mersenne_creation(); print_out(); //cout << "Last Digit:" << creation[max_array_size-5] << creation[max_array_size-4] << creation[max_array_size-3] << creation[max_array_size-2] << creation[max_array_size-1] ; }