Here are my comments:
– In the first hint, you say the 4th Z corresponds to a very large M, but M is not defined in the problem description.
– The fourth hint say that Z must be a subclass of R, and R a subclass of P, but you defined Z as the base class, and both R and P as subclasses of Z.
Let’s analyze this:
Z must comply with:
-Z must be prime
-Z =numberOfDigits(R)
R must comply with:
-R must be prime
-R = (2^P) – 1
P must comply with:
-P must be prime.
What is the number with less constraints ?
I think it is P, so the base class should be P (as specified in the fourth hint) which is just a simple prime number.
Then R should extend P, and add a new class member for its P value
Then Z should extend R, and add a new class member for its R value
Then, I would create a new class for the Mageua Senoko serie, being this class who do the actual verifications/calculation to get the first, second, third, and fourth Z numbers.
You need a function to verify if a given number is prime. Here is an example, but you need to be sure that there is no a more efficient way to to it.
<pre>int isPrime(int n) {
for (i=2; i<=(int)(n/2); i++){
int m = n%i;
if (m==0){
break;
}
}
if(i == j)
return 1;
else
return 0;
}</pre>
Hope this helps.
-Carlosdl
Discuss This Question: