Sunday, 21 September 2014

mathematics - Madam I m Adam..please don’t get mad..you will no longer be prime


Take away $ \overline{MAD} $ from $ \overline{MADMADAM} $ to make her prime. $ \overline{ADAM} $ is prime too if he does not get mad: $ \overline{MADADAM}. $


$ M, A, D $ are 3 distinct digits that are to be determined by you so that the statements in this puzzle are true.



Answer



So, we have two prime numbers (MADMADAM-MAD, ADAM).


Consequently, from a more mathematical standpoint,



$M*10,010,001 + A* 1,001,010 + D*100,100 - (M*100 + A*10 + D)$ is prime, as is $A*1,010 + D*100 + M$.




I ran this through a little program that I wrote, and I discovered that there are three distinct solution sets. They are:





  1. M: 1 A: 5 D: 8 --> $15,815,851 - 158 = 15,815,693‬$, which is prime. $5851$ is also prime.







  2. M: 3 A: 1 D: 6 --> $31,631,613 - 316 = 31,631,297‬$, which is prime. $1613$ is also prime.






  3. M: 3 A: 5 D: 6 --> $35,635,653 - 356 = 35,635,297$, which is prime. $5653$ is also prime.





If you're interested, here's the Java program that I wrote to find the answer. It probably isn't super efficient, but it works.





public class Test {

public static void main(String[] args) {
int big = 0;
for(int i = 1; i<=9; i++) {
for(int j = 1; j<=9; j++) {
for(int k = 0; k<=9; k++) { //k (or d) is the only digit which could be 0.
if(isPrime(i*10010001 + j* 1001010 + k*100100 - (i*100 + j*10 + k))&&

isPrime(j*1010 + k*100 + i)) {
big = i*10010001 + j* 1001010 + k*100100 - (i*100 + j*10 + k);
System.out.println("M: " + i + " A: " + j + " D: " + k);
System.out.println(""+i+j+k+i+j+k+j+i+"-"+ i+j+k+"="+big+
", which is prime. "+j+k+j+i+" is also prime.\n");
}
}
}
}
}

public static boolean isPrime(int i) {
boolean prime = true;
for(int j = 2; j<=i/2; j++) {
if (i%j==0) {
prime = false;
break;
}
}
return prime;
}

}

No comments:

Post a Comment

Understanding Stagnation point in pitot fluid

What is stagnation point in fluid mechanics. At the open end of the pitot tube the velocity of the fluid becomes zero.But that should result...