Menu Close

Question-190285




Question Number 190285 by Abdullahrussell last updated on 31/Mar/23
Commented by ARUNG_Brandon_MBU last updated on 31/Mar/23
#include <stdio.h> int main(void) { unsigned int a, b; for (a = 100; a<1000; a++) { for (b = 300; b<1000; b++) { if (1001*a+1 == b*b) goto loopend; } } loopend: printf ("a = %u, b = %u", a, b); return 0; }
Commented by ARUNG_Brandon_MBU last updated on 31/Mar/23
Output: a = 183, b = 428
Commented by ARUNG_Brandon_MBU last updated on 31/Mar/23
Sorry! plaintext can only be written as comments not answers.
Commented by Rasheed.Sindhi last updated on 01/Apr/23
However you can write your solution as an 'Answer' in the following way: Empty answer +comment consisting plain text.
Commented by ARUNG_Brandon_MBU last updated on 01/Apr/23
���� ThAnKs
Answered by talminator2856792 last updated on 31/Mar/23
  b^2  − 1 = 1001a    (b − 1)(b + 1) = 1001a    (((b − 1)(b + 1))/(1001)) = a    (((b − 1)(b + 1))/(7 × 11 × 13 )) = a    each of 7, 11 and 13 must divide either b − 1 or b + 1      now the necessary combinations for multiplying 7, 11, 13 must be checked.      we have six cases:        one of the cases:    b + 1 is divisible by 7 × 11 and b − 1 divisible by 13      this could be expressed as    77x −2 ≡ 0 (mod 13)     ⇒ 77x ≡ 2 (mod 13) for some non negative x.    77 ≡ 12 (mod 13)    x = 11    b + 1 = 847      b = 846    a = 715        after applying this approach to all other cases      the following case yields the value for a that satisfies the conditions.         b + 1 is divisible by 11 × 13 and b − 1 divisible by 7      143x − 2 ≡ 0 (mod 7)    ⇒ 143x ≡ 2 (mod 7)    143 ≡ 3 (mod 7)    x = 3    b + 1 = 429    b = 428        a = 183
$$\:\:{b}^{\mathrm{2}} \:−\:\mathrm{1}\:=\:\mathrm{1001}{a} \\ $$$$\:\:\left({b}\:−\:\mathrm{1}\right)\left({b}\:+\:\mathrm{1}\right)\:=\:\mathrm{1001}{a} \\ $$$$\:\:\frac{\left({b}\:−\:\mathrm{1}\right)\left({b}\:+\:\mathrm{1}\right)}{\mathrm{1001}}\:=\:{a} \\ $$$$\:\:\frac{\left({b}\:−\:\mathrm{1}\right)\left({b}\:+\:\mathrm{1}\right)}{\mathrm{7}\:×\:\mathrm{11}\:×\:\mathrm{13}\:}\:=\:{a} \\ $$$$\:\:\mathrm{each}\:\mathrm{of}\:\mathrm{7},\:\mathrm{11}\:\mathrm{and}\:\mathrm{13}\:\mathrm{must}\:\mathrm{divide}\:\mathrm{either}\:{b}\:−\:\mathrm{1}\:\mathrm{or}\:{b}\:+\:\mathrm{1}\:\: \\ $$$$\:\:\mathrm{now}\:\mathrm{the}\:\mathrm{necessary}\:\mathrm{combinations}\:\mathrm{for}\:\mathrm{multiplying}\:\mathrm{7},\:\mathrm{11},\:\mathrm{13}\:\mathrm{must}\:\mathrm{be}\:\mathrm{checked}.\:\: \\ $$$$\:\:\mathrm{we}\:\mathrm{have}\:\mathrm{six}\:\mathrm{cases}: \\ $$$$\:\: \\ $$$$\:\:\mathrm{one}\:\mathrm{of}\:\mathrm{the}\:\mathrm{cases}: \\ $$$$\:\:{b}\:+\:\mathrm{1}\:\mathrm{is}\:\mathrm{divisible}\:\mathrm{by}\:\mathrm{7}\:×\:\mathrm{11}\:\mathrm{and}\:{b}\:−\:\mathrm{1}\:\mathrm{divisible}\:\mathrm{by}\:\mathrm{13}\:\: \\ $$$$\:\:\mathrm{this}\:\mathrm{could}\:\mathrm{be}\:\mathrm{expressed}\:\mathrm{as} \\ $$$$\:\:\mathrm{77}{x}\:−\mathrm{2}\:\equiv\:\mathrm{0}\:\left(\mathrm{mod}\:\mathrm{13}\right)\: \\ $$$$\:\:\Rightarrow\:\mathrm{77}{x}\:\equiv\:\mathrm{2}\:\left(\mathrm{mod}\:\mathrm{13}\right)\:\mathrm{for}\:\mathrm{some}\:\mathrm{non}\:\mathrm{negative}\:{x}. \\ $$$$\:\:\mathrm{77}\:\equiv\:\mathrm{12}\:\left(\mathrm{mod}\:\mathrm{13}\right) \\ $$$$\:\:{x}\:=\:\mathrm{11} \\ $$$$\:\:{b}\:+\:\mathrm{1}\:=\:\mathrm{847}\:\: \\ $$$$\:\:{b}\:=\:\mathrm{846} \\ $$$$\:\:{a}\:=\:\mathrm{715} \\ $$$$\:\: \\ $$$$\:\:\mathrm{after}\:\mathrm{applying}\:\mathrm{this}\:\mathrm{approach}\:\mathrm{to}\:\mathrm{all}\:\mathrm{other}\:\mathrm{cases}\:\: \\ $$$$\:\:\mathrm{the}\:\mathrm{following}\:\mathrm{case}\:\mathrm{yields}\:\mathrm{the}\:\mathrm{value}\:\mathrm{for}\:{a}\:\mathrm{that}\:\mathrm{satisfies}\:\mathrm{the}\:\mathrm{conditions}.\:\: \\ $$$$\: \\ $$$$\:\:{b}\:+\:\mathrm{1}\:\mathrm{is}\:\mathrm{divisible}\:\mathrm{by}\:\mathrm{11}\:×\:\mathrm{13}\:\mathrm{and}\:{b}\:−\:\mathrm{1}\:\mathrm{divisible}\:\mathrm{by}\:\mathrm{7}\:\: \\ $$$$\:\:\mathrm{143}{x}\:−\:\mathrm{2}\:\equiv\:\mathrm{0}\:\left(\mathrm{mod}\:\mathrm{7}\right) \\ $$$$\:\:\Rightarrow\:\mathrm{143}{x}\:\equiv\:\mathrm{2}\:\left(\mathrm{mod}\:\mathrm{7}\right) \\ $$$$\:\:\mathrm{143}\:\equiv\:\mathrm{3}\:\left(\mathrm{mod}\:\mathrm{7}\right) \\ $$$$\:\:{x}\:=\:\mathrm{3} \\ $$$$\:\:{b}\:+\:\mathrm{1}\:=\:\mathrm{429} \\ $$$$\:\:{b}\:=\:\mathrm{428} \\ $$$$\:\: \\ $$$$\:\:{a}\:=\:\mathrm{183} \\ $$

Leave a Reply

Your email address will not be published. Required fields are marked *