HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →
Live examsInternational live exams are comingTell us which exam you want first. Timed practice papers are open now.See what is coming →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Space Science and Astronomy
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Problems
  2. /A machine prints a code x from 0 to 37 that must satisfy 14x ≡ 22 pmod38…
HardMathematicsHigh School (11–12)Number TheoryNumericalOlympiad

A machine prints a code x from 0 to 37 that must satisfy 14x ≡ 22 pmod38…

StemPy LabContributed by StemPy Lab

Try it on paper first. A hint, the key idea and the worked solution are here when you need them.

A machine prints a code xxx from 000 to 373737 that must satisfy 14x≡22(mod38)14x \equiv 22 \pmod{38}14x≡22(mod38). Decide first whether any such code exists. Then find how many codes from 000 to 373737 work, the smallest one and the largest one. Show the step where you divide by the gcd, and say why you may not simply cancel 222 from 141414 and 222222 alone.

Check your answer

Work it out on paper, then type your number. The answer itself stays hidden.

Need a reminder? The key ideaShowHide

ax≡b(modm)ax \equiv b \pmod max≡b(modm) is solvable exactly when d=gcd⁡(a,m)d = \gcd(a, m)d=gcd(a,m) divides bbb, and then it has ddd solutions modulo mmm:

ax≡b(modm)  ⟺  adx≡bd(modmd).\displaystyle ax \equiv b \pmod m \iff \tfrac{a}{d}x \equiv \tfrac{b}{d} \pmod{\tfrac{m}{d}}.ax≡b(modm)⟺da​x≡db​(moddm​).

The worked solution

Check an answer or open a hint to unlock the worked solution.

Have you tried it?

Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.

Given. 14x≡22(mod38)14x \equiv 22 \pmod{38}14x≡22(mod38) with 0≤x≤370 \le x \le 370≤x≤37.

Plan. Divide by d=gcd⁡(14,38)d = \gcd(14, 38)d=gcd(14,38), solve modulo 38/d38 / d38/d, and list the ddd solutions.

Step 1. The gcd. gcd⁡(14,38)=2\gcd(14, 38) = 2gcd(14,38)=2 and 2∣222 \mid 222∣22. So there are exactly 222 solutions modulo 383838.

Step 2. Divide everything by 2. 7x≡11(mod19)7x \equiv 11 \pmod{19}7x≡11(mod19). The modulus is halved too: cancelling 222 from 141414 and 222222 alone would keep the modulus 383838 and lose a solution.

Step 3. Invert 7 modulo 19. 7×11=77=4×19+17 \times 11 = 77 = 4 \times 19 + 17×11=77=4×19+1, so 7−1≡117^{-1} \equiv 117−1≡11.

Step 4. Solve. x≡11×11=121=6×19+7≡7(mod19)x \equiv 11 \times 11 = 121 = 6 \times 19 + 7 \equiv 7 \pmod{19}x≡11×11=121=6×19+7≡7(mod19).

Step 5. Back to modulo 38. x=7x = 7x=7 or x=7+19=26x = 7 + 19 = 26x=7+19=26.

Check. 14×7=98=2×38+2214 \times 7 = 98 = 2 \times 38 + 2214×7=98=2×38+22 and 14×26=364=9×38+2214 \times 26 = 364 = 9 \times 38 + 2214×26=364=9×38+22. Both work.

Answer: 222 codes, the smallest 777 and the largest 262626.

Log in to save this for later
← All Problems
← A twelve-digit serial number is N = 123 456 789 123…A ring has 89 cells, numbered 0 to 88 clockwise… →
More onNumber Theory

Discussion (0)

Log in to join the discussion.

Loading…

More on this topic

  1. The triangular numbers are 1, 3, 6, 10, …, where the nth one is (n(n + 1))/2…Advanced
  2. Prove that the equation x³ + y³ + z³ = n has no solution in integers when n leaves remainder 4 or 5…Advanced
  3. Find every triple of positive integers a ≤ b ≤ c with 1/a + 1/b + 1/c = 1, and prove that there are…Advanced
  4. Find all pairs of positive integers (x, y) with x² - y² = 945…Hard
  5. A teacher wants a list of every primitive Pythagorean triple whose hypotenuse is less than 100…Advanced
All problems on this topic →