# I don't know the two numbers... but now I do

Two perfect logicians, Summer and Proctor, are told that integers 𝑥 and 𝑦 have been chosen such that 1 < 𝑥 < 𝑦 and 𝑥 + 𝑦 < 100. Summer is given the value 𝑥 + 𝑦 and Proctor is given the value 𝑥 ⋅ 𝑦. They then have the following conversation.

• Proctor: "I cannot determine the two numbers."
• Summer: "I knew that."
• Proctor: "Now I can determine them."
• Summer: "So can I."

Given that the above statements are true, what are the two numbers?

You may want to use a computer to assist you.

• to confirm, they already know that $x$ and $y$ are not equal and not equal to 1 at the start of the problem. May 19, 2014 at 14:14
• @kaine Yes, those facts are both evidenced by the $1 < x < y$ condition. May 19, 2014 at 14:17
• qbyte.org/puzzles/p003s.html Jul 6, 2020 at 7:14

Let 𝑃 = 𝑥 ⋅ 𝑦 and 𝑆 = 𝑥 + 𝑦.

If Proctor could not determine the two numbers offhand, then there must be at least two valid factorizations of 𝑃, which means that 𝑃 cannot be the product of two primes.

And if Summer knew that Proctor could not determine the two numbers, then every possible pair of 𝑥 and 𝑦 that add up to 𝑆 must have a product that is not a product of two primes - i.e. no two primes can sum to 𝑥 and 𝑦. This gives 11, 17, 23, 27, 29, etc. (in general, every odd composite number plus 2) as possible values of 𝑆, because odd prime numbers plus 2 have 2 and 𝑆 - 2 as the prime numbers that sum to it, and any even number greater than or equal to 4 can be represented as the sum of two primes, by the Goldbach conjecture which has been verified up to 100.

Proctor knows this as well. If he can now determine the two numbers, then out of all of 𝑃's factorizations, only one of them add up to one of those possible values of 𝑆. For example, if 𝑃 = 24, then only 3 and 8 add up to a number in that list. (The other factorizations give 1 + 24 = 25, 2 + 12 = 14, and 4 + 6 = 10, none of which are in the list.)

Summer knows this as well. But if Summer can also figure out what 𝑃 is, then the number of 𝑆 must also have a unique 𝑃 for which a unique 𝑆 exists. Our value of 𝑃 = 24 above gives 𝑆 = 11, which is not the right answer because 𝑃 = 18 gives (2, 9) as another solution to 𝑆 = 11, and so our value of 𝑃 is not unique.

With some brute-force searching by going through all possible values of 𝑃 and checking their respective unique values of 𝑆, we find that only 𝑆 = 17 has only one corresponding 𝑃 value, which is 𝑃 = 52.

So, 𝑆 = 17 and 𝑃 = 52, and 𝑥 = 4 and 𝑦 = 13.

• I've upvoted. I think it's sufficient to say that brute-force is required at some step, and I like the solution reduction.
– user20
May 19, 2014 at 15:21
• Also I think this is a good time for me to try to get people to read this post May 19, 2014 at 15:25
• @JoeZ. Nice solution. I was on the same path. I wrote a C++ program to compute the table OP mentioned. It's not documented (or optimized, I was in a hurry) but I managed to reach S = 17 in the end. May 19, 2014 at 15:26
• I think you made a mistake in the very first line.
– SF.
May 19, 2014 at 17:04
• I've corrected it. The rest of the solution assumes the corrected version.
– user88
May 19, 2014 at 17:15

I used the same brute force approach described by the other answers, but I thought I'd share my (Scala) code to show how the answer can be computed with a functional language:

case class Combination(x:Int, y: Int) {
def sum = x + y
def prod = x * y
}

val allCombinations = for {
x <- 2 to 98
y <- (x + 1) to (100 - x - 1)
} yield Combination(x, y)
// allCombinations.length == 2304

val combinationsBySum = allCombinations.groupBy(_.sum)
val combinationsByProd = allCombinations.groupBy(_.prod)

// Step 1 -> The product matches multiple combinations (it's not semiprime):
val possibleProds = combinationsByProd.filter(_._2.length != 1).keys.toSet
//possibleProds.size == 563

// Step 2 -> The sum implies that the product is in possibleProds:
val possibleSums = combinationsBySum.filter(
_._2.forall(comb => possibleProds.contains(comb.prod))
).keys.toSet
// possibleSums.size == 10

// Step 3 -> Only one combination matching the product has a possible sum per step 2:
val possibleProds2 = possibleProds.filter{(prod) =>
combinationsByProd(prod).count(comb => possibleSums.contains(comb.sum)) == 1
}
// possibleProds2.size == 86

// Statement 4 -> Only one combination matching the sum has a possible product per step 3:
val possibleSums2 = possibleSums.filter{(sum) =>
combinationsBySum(sum).count(comb => possibleProds2.contains(comb.prod)) == 1
}

possibleSums2.flatMap(combinationsBySum).filter(comb => possibleProds2.contains(comb.prod))


My intervention here appeared to be too late and nothing but a supplementary clarification for confused people.

I wrote a matlab code to illustrate why cannot any two numbers be or can be applied ,this is based on mathematical expression:

$$\ (x,y)\ \epsilon \ \mathbb{N} \ \ x+y<100\ ,\forall n\ \epsilon\mathbb{N}<x+y \ \ : x+y-n\ \ not\ prime \ or\ n \ not\ prime\ \&\&\ \forall k\ prime \ factor\ of \ n \ if \ x+y-n \ primes \ (x+y-n)*k <100,\forall \ (x_{0},y_{0})\epsilon\mathbb{N} \ \ x_{0}+y_{0}<100,x_{0}y_{0}=xy:x_{0}\ and \ y_{0}\ \ prime \ \ or \ \ \exists n<x_{0}+y_{0} \ :[\ x_{0}+y_{0}-n \ prime \ \& \forall k \ (x_{0}+y_{0}-n)*\frac{n}{k}>100 ] \ \ \ \&\& \ \ \ \forall \ (x_{1},y_{1})\epsilon\mathbb{N}\ \ x_{1}+ y_{1}<100,x-x_{1}=y_{1}-y, \ (x_{1}\ , \ y_{1})\ verify\ the \ last \ condition \ which \ means \ dont \ verify \ the \ first \ condition$$

For those who doesnt master matlab i have pastbin the results all you have to do is find (x=* ,y=*) with the suspected values

Code:

k = 1;begin=1;fid = fopen('numbers.txt', 'w');
for i = 2: 100
feu = 0;
for j = 2: i / 2
if mod(i, j) == 0
feu = 1;
break;
end
end
if feu == 0
l(k) = i;
k = k + 1;
end
end
for  i = 1: k - 1
tmp = 1;
for  j = 1: 20
tmp = tmp * l(i);
if tmp >= 100
m(i) = j;
break
end
end
end
for ii = 1: k
vect(ii) = 0;
end
for ii = 0: (k - 2)
m(k - ii) = m(k - ii - 1);
l(k - ii) = l(k - ii - 1);
end
for bb=0:1000000
if begin==0
fid = fopen('draft.txt', 'w');
end
m(1) = 1;o=1;oo=1;
if begin==0
for cc=0:10000
val1=input('\nenter a number \n');val2=input('\nenter a second number \n');nb1=val1;nb2=val2;val1=min(nb1,nb2);val2=max(nb1,nb2);
if val1==1 | val2>=100
fprintf('enter valid values\n');
else
break;
end
end
end
for jj = 1: 6885
cunt = 0;tmp = 1;feu = 0; nb1=0;nb2=0;
for i= 2: (k)
if (vect(i) == mod(vect(i) + floor(((mod(vect(i - 1) - 1, m(i - 1)) + 1) / m(i - 1))), m(i)))
feu = 1;
end
if feu == 0
vect(i) = mod(vect(i) + floor(((mod(vect(i - 1) - 1, m(i - 1)) + 1) / m(i - 1))), m(i));current = i;
end
tmp = tmp * l(i) ^ vect(i);
if tmp > 10000
if feu == 1
for ll = 2: current
if m(ll)~=0
vect(ll) = m(ll) - 1;
end
end
break;
end
end
end
if tmp < 10000 & tmp ~= 1
kk=k;lim=1;
for iii = 2: k
if vect(iii)~=0
kk=iii+1;mm(iii) = vect(iii)  +1;lim=lim*(mm(iii));
else
mm(iii)=0;
end
vectt(iii) = 0;
end
if kk>k
kk= k;
end
mm(1) = 1;vectt(1) = 0;
for jjj = 1: lim + 1
tmpp = 1;feu = 0;tmmp = 1;ilast=1;
for ii = 2: (kk)
if mm(ii)~=0
if(jjj~=1 )
if (vectt(ii) == mod(vectt(ii) + floor(((mod(vectt(ilast) - 1, mm(ilast)) + 1) / mm(ilast))), mm(ii)))
feu = 1;
end
if feu == 0
vectt(ii) = mod(vectt(ii) + floor((mod(vectt(ilast) - 1, mm(ilast)) + 1) / mm(ilast)), mm(ii));currentt = ii;
end
end
tmpp = tmpp * l(ii) ^ vectt(ii);tmmp = tmmp * l(ii) ^ (vect(ii) - vectt(ii));
if tmpp > 100 | tmmp > 100 | tmpp == 1 | tmmp == 1
if feu == 1
if tmpp> 100
for ll = 2: currentt
if mm(ll)~=0
vectt(ll) = mm(ll) - 1;
end
end
end
break;
end
end
ilast=ii;
end
end
if tmpp < 100 & tmmp < 100 & tmpp ~= 1 & tmmp ~= 1
if begin==1
fprintf('-  %d %%  -\n',floor(100*jj/6885));
end
sum = tmpp + tmmp;prem = 0;sec = 0;niv = k;
for iij = 0: niv - 2
if l(k - iij) <= sum
niv = k - iij;break;
end
end
if(sum>100)
prem=1000;
end
last = 2;
for iij = 2: niv
if prem ~= 0 | sec ~= 0
break;
end
if l(iij) == sum - 2
prem = sum-2;break;
end
for iijj = 0: niv - 2
if(niv-iijj<iij)
break;
end
if(prem ~= 0|sec ~= 0)
break;
end
if l(niv - iijj) == sum - 2
prem = sum-2;break;
end
for ji = l(iij - 1) + 1: l(iij) - 1
if l(niv - iijj) == sum - ji
if l(last) * l(last) == ji
if l(niv - iijj) * l(last) > 100
sec = l(niv - iijj) ;prem=l(last);break;
end
if last~= k
last = last + 1;
end
end
end
end
if l(niv - iijj) <= sum - l(iij)
if l(niv - iijj) == sum - l(iij)
prem= l(iij) ;break;
end
niv = niv - iijj;
break;
end
end
end
res(o) = tmmp;res(o+1) = tmpp;ress(o) = prem;ress(o+1) = sec;o = o + 2;
if prem == 0 & sec == 0
valeur=tmmp;
if tmmp~=nb1 & tmmp~=nb2
cunt = cunt + 1;nb1=min(tmmp,tmpp);nb2=max(tmmp,tmpp);
end
end
end
for ij = 2: kk
if vectt(ij) ~= mm(ij) - 1 & mm(ij) ~= 0
break;
end
end
if ij == kk
break;
end
end
end
res(o)=0;ress(o)=cunt;o=o+1;
if (vect(k) == m(k) - 1)
for ijij = 2: k
if vect(ijij)  ~= m(ijij) - 1
break;
end
end
if ijij == k
break;
end
end
if(cunt>1 | cunt==0)
for ij=0:2:o-3
if res(o-2-ij)==0
o=o-1-ij;
break
end
if ress(o-2-ij)==0 & ress(o-2-ij-1)==0
if begin==0 & val1==min(res(o-2-ij-1),res(o-2-ij)) & val2==max(res(o-2-ij-1),res(o-2-ij))
fprintf('(x=%d ,y=%d) is rejected because there exists (x0,y0)  :\n',res(o-2-ij-1),res(o-2-ij));
end
fprintf(fid,'(x=%d ,y=%d) is rejected because there exists (x0,y0)  :\n',res(o-2-ij-1),res(o-2-ij));
for iij=0:2:o-3
if res(o-2-iij)==0
break
end
if res(o-2-ij)~=res(o-2-iij) & res(o-2-ij)~=res(o-2-iij-1)
if ress(o-2-iij)==0 & ress(o-2-iij-1)==0
if begin==0 & val1==min(res(o-2-ij-1),res(o-2-ij)) & val2==max(res(o-2-ij-1),res(o-2-ij))
fprintf('(x0=%d ,y0=%d ) where xy = x0*y0  and they both verify conditions \nthe proctor wouldnt say  "Now I can determine them."!\n\n',res(o-2-iij-1),res(o-2-iij));break;
end
fprintf(fid,'(x0=%d ,y0=%d ) where xy = x0*y0  and they both verify conditions \nthe proctor wouldnt say  "Now I can determine them."!\n\n',res(o-2-iij-1),res(o-2-iij));break;
end
end
end
else
if begin==0 & val1==min(res(o-2-ij-1),res(o-2-ij)) & val2==max(res(o-2-ij-1),res(o-2-ij))
fprintf('(x=%d ,y=%d) is rejected because   :\n',res(o-2-ij-1),res(o-2-ij));
end
fprintf(fid,'(x=%d ,y=%d) is rejected because   :\n',res(o-2-ij-1),res(o-2-ij));
if ress(o-2-ij)==0
if ress(o-2-ij-1)==1000
if begin==0 & val1==min(res(o-2-ij-1),res(o-2-ij)) & val2==max(res(o-2-ij-1),res(o-2-ij))
fprintf('x+y = %d bigger than 100 \n\n\n',res(o-2-ij-1)+res(o-2-ij));
break;
end
fprintf(fid,'x+y = %d bigger than 100 \n\n\n',res(o-2-ij-1)+res(o-2-ij));
else
if begin==0 & val1==min(res(o-2-ij-1),res(o-2-ij)) & val2==max(res(o-2-ij-1),res(o-2-ij))
if res(o-2-ij)==ress(o-3-ij) | res(o-3-ij)==ress(o-2-ij-1)
fprintf('%d and %d are primes \nthe proctor wudnt say  "I cannot determine the two numbers."!\n\n',ress(o-2-ij-1),res(o-2-ij-1)+res(o-2-ij)-ress(o-3-ij));
else
fprintf('x+y-k = %d and k = %d primes \nthe summer wudnt say  "I knew that."!\n\n',ress(o-2-ij-1),res(o-2-ij-1)+res(o-2-ij)-ress(o-3-ij));
end
break;
end
if res(o-2-ij)==ress(o-3-ij) | res(o-3-ij)==ress(o-2-ij-1)
fprintf(fid,'%d and %d are primes \nthe proctor wudnt say  "I cannot determine the two numbers."!\n\n',ress(o-2-ij-1),res(o-2-ij-1)+res(o-2-ij)-ress(o-3-ij));
else
fprintf(fid,'x+y-k = %d and k = %d primes \nthe summer wudnt say  "I knew that."!\n\n',ress(o-2-ij-1),res(o-2-ij-1)+res(o-2-ij)-ress(o-3-ij));
end
end
else
if ress(o-2-ij-1)+ress(o-2-ij)==res(o-2-ij-1)+res(o-2-ij)
if begin==0 & val1==min(res(o-2-ij-1),res(o-2-ij)) & val2==max(res(o-2-ij-1),res(o-2-ij))
fprintf('it exists a prime number k=%d where (x+y-k)*k = %d*%d =%d  bigger than 100 \nthe summer wudnt say  "I knew that."!\n\n',min(ress(o-2-ij-1),ress(o-2-ij)),res(o-2-ij-1)+res(o-2-ij)-min(ress(o-2-ij-1),ress(o-2-ij)),min(ress(o-2-ij-1),ress(o-2-ij)),ress(o-2-ij-1)*ress(o-2-ij));
break;
end
fprintf(fid,'it exists a prime number k=%d where (x+y-k)*k = %d*%d =%d  bigger than 100 \nthe summer wudnt say  "I knew that."!\n\n',min(ress(o-2-ij-1),ress(o-2-ij)),res(o-2-ij-1)+res(o-2-ij)-min(ress(o-2-ij-1),ress(o-2-ij)),min(ress(o-2-ij-1),ress(o-2-ij)),ress(o-2-ij-1)*ress(o-2-ij));
else
if begin==0 & val1==min(res(o-2-ij-1),res(o-2-ij)) & val2==max(res(o-2-ij-1),res(o-2-ij))
fprintf('it exists a number n=%d , where the smallest prime number k=%d < n verifies (x+y-n)*k = %d*%d = %d  bigger than 100 \nthe summer wudnt say  "I knew that."!\n\n',res(o-2-ij-1)+res(o-2-ij)-max(ress(o-2-ij-1),ress(o-2-ij)),min(ress(o-2-ij-1),ress(o-2-ij)),max(ress(o-2-ij-1),ress(o-2-ij)),min(ress(o-2-ij-1),ress(o-2-ij)),ress(o-2-ij-1)*ress(o-2-ij));
break;
end
fprintf(fid,'it exists a number n=%d , where the smallest prime number k=%d < n verifies (x+y-n)*k = %d*%d = %d  bigger than 100 \nthe summer wudnt say  "I knew that."!\n\n',res(o-2-ij-1)+res(o-2-ij)-max(ress(o-2-ij-1),ress(o-2-ij)),min(ress(o-2-ij-1),ress(o-2-ij)),max(ress(o-2-ij-1),ress(o-2-ij)),min(ress(o-2-ij-1),ress(o-2-ij)),ress(o-2-ij-1)*ress(o-2-ij));
end
end
end

end

elseif(cunt==1)
feu=0;
for iij=0:2:o-3
if (o-2-iij<2)
break
end
if res(o-2-iij)==0
if iij==2 |(iij==4 & res(o-2)==res(o-5) & res(o-3)==res(o-4))
if begin==0 & val1==min(nb1,nb2) & val2==max(nb1,nb2)
fprintf('(x=%d ,y=%d) is rejected because x * y dont have other valid factors \nthe proctor wudnt say  "I cannot determine the two numbers."!\n\n',nb1,nb2);feu=1;
break;
end
fprintf(fid,'(x=%d ,y=%d) is rejected because x * y dont have other valid factors  \nthe proctor wudnt say  "I cannot determine the two numbers."!\n\n',nb1,nb2);feu=1;
end
break;
end
if ress(o-2-iij-1)~=0 & res(o-2-iij)~=0 & res(o-3-iij)~=0
if begin==0 & val1==min(res(o-2-iij-1),res(o-2-iij)) & val2==max(res(o-2-iij-1),res(o-2-iij))
fprintf('(x=%d ,y=%d) is rejected because   :\n',res(o-2-iij-1),res(o-2-iij));
end
fprintf(fid,'(x=%d ,y=%d) is rejected because   :\n',res(o-2-iij-1),res(o-2-iij));
if ress(o-2-iij)==0
if ress(o-2-iij-1)==1000
if begin==0 & val1==min(res(o-2-iij-1),res(o-2-iij)) & val2==max(res(o-2-iij-1),res(o-2-iij))
fprintf('x+y = %d bigger than 100 \n\n\n',res(o-2-iij-1)+res(o-2-iij));
break;
end
fprintf(fid,'x+y = %d bigger than 100 \n\n\n',res(o-2-iij-1)+res(o-2-iij));
else
if begin==0 & val1==min(res(o-2-iij-1),res(o-2-iij)) & val2==max(res(o-2-iij-1),res(o-2-iij))
if res(o-2-iij)==ress(o-3-iij) | res(o-3-iij)==ress(o-2-iij-1)
fprintf('%d and %d are primes \nthe proctor wudnt say  "I cannot determine the two numbers."!\n\n',ress(o-2-iij-1),res(o-2-iij-1)+res(o-2-iij)-ress(o-3-iij));
else
fprintf('x+y-k = %d and k = %d primes \nthe summer wudnt say  "I knew that."!\n\n',ress(o-2-iij-1),res(o-2-iij-1)+res(o-2-iij)-ress(o-3-iij));
end
break;
end
if res(o-2-iij)==ress(o-3-iij) | res(o-3-iij)==ress(o-2-iij-1)
fprintf(fid,'%d and %d are primes \nthe proctor wudnt say  "I cannot determine the two numbers."!\n\n',ress(o-2-iij-1),res(o-2-iij-1)+res(o-2-iij)-ress(o-3-iij));
else
fprintf(fid,'x+y-k = %d and k = %d primes \nthe summer wudnt say  "I knew that."!\n\n',ress(o-2-iij-1),res(o-2-iij-1)+res(o-2-iij)-ress(o-3-iij));
end
end
else
if ress(o-2-iij-1)+ress(o-2-iij)==res(o-2-iij-1)+res(o-2-iij)
if begin==0 & val1==min(res(o-2-iij-1),res(o-2-iij)) & val2==max(res(o-2-iij-1),res(o-2-iij))
fprintf('it exists a prime number k=%d where (x+y-k)*k = %d*%d =%d  bigger than 100 \nthe summer wudnt say  "I knew that."!\n\n',min(ress(o-2-iij-1),ress(o-2-iij)),res(o-2-iij-1)+res(o-2-iij)-min(ress(o-2-iij-1),ress(o-2-iij)),min(ress(o-2-iij-1),ress(o-2-iij)),ress(o-2-iij-1)*ress(o-2-iij));
break;
end
fprintf(fid,'it exists a prime number k=%d where (x+y-k)*k = %d*%d =%d  bigger than 100 \nthe summer wudnt say  "I knew that."!\n\n',min(ress(o-2-iij-1),ress(o-2-iij)),res(o-2-iij-1)+res(o-2-iij)-min(ress(o-2-iij-1),ress(o-2-iij)),min(ress(o-2-iij-1),ress(o-2-iij)),ress(o-2-iij-1)*ress(o-2-iij));
else
if begin==0 & val1==min(res(o-2-iij-1),res(o-2-iij)) & val2==max(res(o-2-iij-1),res(o-2-iij))
fprintf('it exists a number n=%d , where the smallest prime number k=%d < n verifies (x+y-n)*k = %d*%d = %d  bigger than 100 \nthe summer wudnt say  "I knew that."!\n\n',res(o-2-iij-1)+res(o-2-iij)-max(ress(o-2-iij-1),ress(o-2-iij)),min(ress(o-2-iij-1),ress(o-2-iij)),max(ress(o-2-iij-1),ress(o-2-iij)),min(ress(o-2-iij-1),ress(o-2-iij)),ress(o-2-iij-1)*ress(o-2-iij));
break;
end
fprintf(fid,'it exists a number n=%d , where the smallest prime number k=%d < n verifies (x+y-n)*k = %d*%d = %d  bigger than 100 \nthe summer wudnt say  "I knew that."!\n\n',res(o-2-iij-1)+res(o-2-iij)-max(ress(o-2-iij-1),ress(o-2-iij)),min(ress(o-2-iij-1),ress(o-2-iij)),max(ress(o-2-iij-1),ress(o-2-iij)),min(ress(o-2-iij-1),ress(o-2-iij)),ress(o-2-iij-1)*ress(o-2-iij));
end
end
end

end
if feu~=1
rest(oo)=nb1;rest(oo+1)=nb2;oo=oo+2;
for iij= 0:2:oo-3
if (nb1==rest(oo-2-iij) & nb2==rest(oo-iij-1))|(nb2==rest(oo-2-iij) & nb1==rest(oo-iij-1))
else
if (nb1-rest(oo-2-iij)==rest(oo-1-iij)-nb1 | nb2-rest(oo-1-iij)==rest(oo-2-iij)-nb1 )
if begin==0 & ( (val1==min(rest(oo-iij-1),rest(oo-2-iij)) & val2==max(rest(oo-iij-1),rest(oo-2-iij))) | (val1==min(nb1,nb2) & val2==max(nb1,nb2)) )
fprintf('(x=%d ,y=%d) and (x0=%d ,y0=%d )  where x-x0 = y0-y = %d are rejected because they both verify conditions \nthe summer wouldnt say "So can I."!\n\n',nb1,nb2,rest(oo-iij-1),rest(oo-2-iij),nb1-rest(oo-iij-1));
break;
end
fprintf(fid,'(x=%d ,y=%d) and (x0=%d ,y0=%d )  where x-x0 = y0-y = %d are rejected because they both verify conditions \nthe summer wouldnt say "So can I."!\n\n',nb1,nb2,rest(oo-iij-1),rest(oo-2-iij),nb1-rest(oo-iij-1));
break;
end
end
end
end
end
end
for ij= 2:2:oo-5
nb1=rest(oo-ij);nb2=rest(oo-ij+1);feu=1;
for iij= ij:2:oo-3
if (nb1-rest(oo-2-iij)==rest(oo-1-iij)-nb1 | nb2-rest(oo-1-iij)==rest(oo-2-iij)-nb1 )
feu=0;rest(oo-iij-1)=0;rest(oo-2-iij)=0;
end
end
if feu==0
rest(oo-ij)=0;rest(oo-ij+1)=0;
end
end
if begin==1
for ij= 2:2:oo-5
nb1=rest(oo-ij);nb2=rest(oo-ij+1);
if nb1~=0 & nb2~=0
fprintf('numbers searched for are :\n\n');
nb1
nb2
break;
end
end
begin=0;
end
fclose(fid);
end


Im pleased to be reported to wichever bug or anomaly detected in my entire post ,plz dont downrate without reason thanks .

Here is the python solution for the same problem. I am not posting the optimized version of the same code as this is more structured and easy to follow with the question statements.

# S does not know the answer
# S knows that P has no unique product, remove them
s = {}
p = {}
for y in range(3, 97):
for x in range(2, min(y, 100-y)):
if p.get(x*y, None) is None:
p[x*y] = set([x+y])
else:
if s.get(x+y, None) is None:
s[x+y] = set([x*y])
else:

for key in list(s):
if len(s[key])==1:
del s[key]
else:
for key2 in s[key]:
if len(p[key2])==1:
del p[key2]
del s[key]
break

for key in list(s):
for key2 in list(s[key]):
for key3 in list(p[key2]):
if s.get(key3,None) is None:
p[key2].remove(key3)

for key in list(s):
for key2 in list(s[key]):
if not len(p[key2])==1:
s[key].remove(key2)

for key in list(s):
if len(s[key])==1:
print(key, list(s[key])[0])
al, be = key, list(s[key])[0]

x, y = (al - (al**2 - 4*be)**0.5)/2, (al + (al**2 - 4*be)**0.5)/2