44
$\begingroup$

Two perfect logicians, Summer and Proctor, are told that integers $x$ and $y$ have been chosen such that $1 < x < y$ and $x+y < 100$. Summer is given the value $x+y$ and Proctor is given the value $x \cdot y$. 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.

$\endgroup$
  • $\begingroup$ to confirm, they already know that $x$ and $y$ are not equal and not equal to 1 at the start of the problem. $\endgroup$ – kaine May 19 '14 at 14:14
  • $\begingroup$ @kaine Yes, those facts are both evidenced by the $1 < x < y$ condition. $\endgroup$ – durron597 May 19 '14 at 14:17
37
$\begingroup$

Let $P = x \cdot y$ and $S = x + y$.

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

And if Summer knew that Proctor could not determine the two numbers, then every possible pair of $x$ and $y$ that add up to $S$ must have a product that is not a product of two primes - i.e. no two primes can sum to $x$ and $y$. This gives $11$, $17$, $23$, $27$, $29$, etc. (in general, every odd composite number plus 2) as possible values of $S$, because odd prime numbers plus 2 have $2$ and $S-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 $P$'s factorizations, only one of them add up to one of those possible values of $S$. For example, if $P = 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 $P$ is, then the number of $S$ must also have a unique $P$ for which a unique $S$ exists. Our value of $P = 24$ above gives $S = 11$, which is not the right answer because $P = 18$ gives $(2, 9)$ as another solution to $S = 11$, and so our value of $P$ is not unique.

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

So, $S = 17$ and $P = 52$, and $x = 4$ and $y = 13$.

$\endgroup$
  • $\begingroup$ I've upvoted. I think it's sufficient to say that brute-force is required at some step, and I like the solution reduction. $\endgroup$ – Aza May 19 '14 at 15:21
  • $\begingroup$ Also I think this is a good time for me to try to get people to read this post $\endgroup$ – durron597 May 19 '14 at 15:25
  • 4
    $\begingroup$ @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. $\endgroup$ – John Bupit May 19 '14 at 15:26
  • $\begingroup$ I think you made a mistake in the very first line. $\endgroup$ – SF. May 19 '14 at 17:04
  • $\begingroup$ I've corrected it. The rest of the solution assumes the corrected version. $\endgroup$ – Joe Z. May 19 '14 at 17:15
3
$\begingroup$

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))
$\endgroup$
2
$\begingroup$

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

part1:http://pastebin.com/raw.php?i=y36fughA

part2:http://pastebin.com/raw.php?i=kfhC5qdw

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 .

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.