Question: Several odd numbers have the property that their value squared + 2 is prime and their value squared 2 is prime. For instance, 3 ^

Several odd numbers have the property that their value squared +2 is prime and their value squared 2 is prime. For instance, 3^2+2=11 and 3^22=7, both of which are prime, so 3 is such a number. Write a program to find and output all such odd numbers between 3 and 1001 with this property. The first five numbers are 3,9,15,21,33. There are 16 additional numbers between 3 and 1001. Your output should be a list of all numbers with this property. Declare any needed variables in C and then enter assembly code to initialize any variables, iterate from 3 to 1001 and for each number, say i, compute i^2+2 and i^22 and determine if both are
prime. To compute if a number is prime, iterate from 2 up to but not including i^2+2/i^2-2 to see if any such value divides into i^2+2/i^2-2. If no divisor is found for either, then leave assembly code to output i. Next, increment i by 2 and repeat until i >1001. To determine if a number divides into another number, put the numerator in the eax, set the edx to 0 and div by the denominator. If the edx is 0 then there is no remainder and so the denominator divides into the numerator and the
numerator is not prime. For simplicity, use the range 2..numerator-1 as your divisor rather than trying to be more efficient. Remember that the only code that should appear in C are your variable declarations and your printf. Once your assembly program is working correctly, copy your output to the bottom of the .c file in comments and submit the one file.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!