University Discrete Math · Sheet 04 of 9 All 9 sheets →
  1. Home
  2. Worksheets
  3. University Discrete Math
  4. Divisibility and Primes
University Discrete Math Divisibility and Primes Free · no sign-up

University Discrete Mathematics — Divisibility and Primes Worksheet

Number theory as this course uses it, from one statement about quotients and remainders. The division algorithm, including the case a dividend below zero makes awkward; remainders carried through an expression by writing the unknown in the form the hypothesis gives; trial division and the stopping rule that makes it finite; gcd, lcm and the divisor count read off prime powers; the Euclidean algorithm; and Bezout's identity, which turns a gcd into a certificate and decides which equations in two integer unknowns can be solved at all. Have a look on this page, then print the free PDF when you want to write on it.

Page 1 of the University Discrete Math Divisibility and Primes practice worksheet

Practice worksheet — free PDF

4 pages 8 questions Letter size, print-ready

No email, no account, no watermark. Teachers: photocopy it for your classes freely. Worked solutions and 5 harder problems come with the University Discrete Math bundle.

All 8 questions

Each question targets one named concept from the sheet. Read them here, or print the PDF — it has working space under each one.

  1. Q1Divisibility and the Division Algorithm

    The division algorithm says: for integers a and b with b>0 there are unique integers q and r with a=bq+r and 0r<b. For each dividend a below, with b=23, find q and r, and say whether 23a.

    1. a=317
    2. a=317
    3. a=92
  2. Q2Divisibility and the Division Algorithm

    An integer n leaves remainder 7 when divided by 9. Using n=9q+7 for some integer q, find the remainder when each of the following is divided by 9.

    1. 4n+5
    2. n2
    3. n
  3. Q3Primes and the Fundamental Theorem of Arithmetic
    1. Decide whether 437 and 401 are prime. Test only the divisors you need, and say why testing those is enough.
    2. Let A=23·32·5·72 and B=2·34·73·11. Write gcd(A,B) and lcm(A,B) as products of prime powers, and find the number of positive divisors of A.

    Use: a positive integer d divides n=p1e1pkek exactly when d=p1f1pkfk with 0fiei for every i, so n has (e1+1)(e2+1)(ek+1) positive divisors.

  4. Q4The Greatest Common Divisor and the Euclidean Algorithm

    Use the Euclidean algorithm to find gcd(1573,1144). Show each division.

  5. Q5The Greatest Common Divisor and the Euclidean Algorithm
    1. Use the Euclidean algorithm to find gcd(4389,2002).
    2. Use gcd(a,b)·lcm(a,b)=ab (for positive a, b) to find lcm(4389,2002).
    3. The gcd of two integers, not both zero, is the largest positive integer dividing both. Find gcd(4389,2002) and gcd(2002,0).
  6. Q6Bezout's Identity and the Extended Euclidean Algorithm

    Use the extended Euclidean algorithm to find gcd(391,299) and integers x, y with 391x+299y=gcd(391,299).

  7. Q7Bezout's Identity and the Extended Euclidean Algorithm

    Bezout's identity says the integers of the form ax+by, with x,y, are exactly the multiples of gcd(a,b).

    1. Explain why 18x+42y=100 has no integer solution.
    2. Find one integer solution of 18x+42y=30.
  8. Q8Synthesis — drawing on several topics in this unit
    1. Use the Euclidean algorithm to find gcd(1309,1001), and write it in the form 1309x+1001y with x,y.
    2. Given that 1001=7·11·13, use your gcd to write 1309 as a product of primes, and find lcm(1309,1001).

The 5 challenge problems for this topic are a separate, paid sheet and are not reproduced here.

What does this set assume? This set assumes Secondary 5 mathematics only — no calculus and no linear algebra, whatever a calendar lists as a prerequisite — plus fluent algebraic manipulation, since most of the work is expanding, collecting and factoring expressions in an unknown integer. It leans on Methods of Proof more than on any other earlier set: divisibility statements are the standard practice ground for a direct proof from the definition and for proof by contradiction, and every question here that says "say why" or "explain why" wants that kind of argument rather than a number. From Sets, Functions and Relations it uses nothing beyond ordinary set language. Deliberately out of this set and this course: integer representation in bases other than ten and bitwise operations, which belong to a computing course; and the Chinese remainder theorem, which is out of the course entirely, so no question asks you to solve a system of congruences. Congruence notation itself is not needed here either — it arrives in the next set, Modular Arithmetic and Cryptography, which is built on the gcd and the extended algorithm this set establishes.

Which course is this for? In the public course calendars of Montreal universities, this material is part of the courses numbered MATH 240, INF1132 and MAT210. Each course orders and weights the topics its own way, so check your own outline for what your exam covers. Which sets match your course.

How to do every concept on this sheet

This is the part worksheet sites usually leave out. Below is the actual reasoning behind each group of questions — not a full solution set, the decisions that get you to one. Read it before you start, or after you get stuck.

The division algorithm, and what makes it an algorithm

The statement Q1 quotes is a theorem about existence and uniqueness: for integers a and b with b > 0 there is exactly one pair q, r with a = bq + r and 0 ≤ r < b. The constraint on r is what makes the pair unique, and it is the whole content of the question. Divisibility is then a special case of it: b | a means the remainder is zero, nothing more.

a = bq + r with 0 ≤ r < b · b | a means r = 0

A dividend below zero is where calculators mislead. Two of Q1's three dividends are negative, and a calculator that truncates towards zero returns a remainder below zero, which the theorem forbids. Choose q so that bq is the largest multiple of b that does not exceed a — that is, round the quotient down, not towards zero — and read r off as a − bq. Then check the inequality 0 ≤ r < b before writing anything else down.

Q1 asks in each part whether 23 | a, and that is answered by the value of r alone, so do not answer it separately by eye. Note that b = 23 is fixed across the three parts and one part's dividend is the negative of another's: it is worth asking yourself, once both are done, how the two pairs (q, r) are related, because that relationship is a small theorem you will use again.

Carrying a remainder through an expression

Q2 is the first real use of the division algorithm as a tool. You are told only that an integer n leaves remainder 7 on division by 9, and asked for the remainders of 4n + 5, n² and −n. The nothing-else-known is deliberate: the answer must hold for every such n.

The substitute-and-regroup method

Three moves, and the third is the one that is skipped.

  1. 1
    Write the hypothesis as an equation

    n = 9q + 7 for some integer q. The question hands you this form; use it rather than a particular n.

  2. 2
    Substitute and expand

    Put 9q + 7 in place of n and expand fully. For n², expand the square — the cross term and the square of the quotient both carry a factor of 9.

  3. 3
    Regroup as 9 (something integer) + r, then fix r

    Collect every term with a factor of 9 into one bracket. What is left over is a plain number, and it need not already satisfy 0 ≤ r < 9. If it does not, move multiples of 9 between the bracket and the leftover until it does.

Step 3 is the marked step. Writing "= 9(…) + 33" and stopping leaves an r outside the allowed range, so it is not the remainder the theorem is about. The same trap appears in reverse in Q2(c), where substituting gives a leftover below zero: add 9 to it and subtract 1 from the bracket. The bracket must still be visibly an integer after the adjustment — that is what licenses the conclusion.

Testing one convenient value of n is a good way to catch an arithmetic slip, but it is not an argument: a single n cannot show that the remainder is the same for all of them. The algebra above is the proof, and it is a direct proof of exactly the kind Methods of Proof drills.

Primes, trial division, and knowing when to stop

Q3(a) asks you to decide primality for two three-digit numbers and — the harder half — to say why the divisors you tested were enough. The justification is the mathematics here; the arithmetic is bookkeeping.

The stopping rule, and its proof in one line. If n is composite, write n = de with d ≤ e. Both factors cannot exceed √n, or their product would exceed n, so the smaller one satisfies d ≤ √n. Every factor has a prime divisor, so n has a prime divisor at most √n. Testing the primes up to √n is therefore exhaustive — and testing composite divisors as well is wasted work, not extra safety.

So for each number in Q3(a): estimate √n by squaring candidates rather than reaching for a decimal, list the primes up to it, and divide by each. Write the short list of primes you tested and the sentence justifying it; a bare verdict with no list answers only half of what was asked.

The fundamental theorem of arithmetic, and reading gcd, lcm and divisors off it

Every integer above 1 is a product of primes in exactly one way up to order. Uniqueness is what makes the rest of Q3(b) mechanical: once two numbers are written over the same set of primes — giving a prime exponent 0 when it is absent — every question about their common factors is a question about exponents, one prime at a time.

gcd: the smaller exponent on each prime · lcm: the larger exponent on each prime

Q3(b) gives A and B already factored, so no factoring is needed; the work is lining the two up over the primes 2, 3, 5, 7 and 11 and comparing exponents in each column. Leave both answers as products of prime powers, as the question asks — multiplying out hides the structure and invites an arithmetic error at the last step.

The divisor count is the same idea. Q3(b) supplies the fact it needs: a divisor of a number is built by choosing, for each prime, any exponent from 0 up to the exponent in the number. So each prime offers one more choice than its exponent, and the choices multiply. Count the choices, do not list the divisors — and apply it to A alone, which is the number the question names.

The Euclidean algorithm

Q4 asks for gcd(1573, 1144) with every division shown. Factoring both numbers would also work on numbers this size, and that is precisely why the question specifies the algorithm: it runs in a handful of steps on numbers far too large to factor, and it is the engine everything in the next set is built on.

One line per division

Each line is the division algorithm applied once.

  1. 1
    Divide the larger by the smaller

    Write it as larger = smaller · q + r, with 0 ≤ r < smaller.

  2. 2
    Shift the pair down

    The old divisor becomes the new dividend, the remainder becomes the new divisor. Repeat.

  3. 3
    Stop at a remainder of zero

    The last nonzero remainder is the gcd. Keep every line: Q6 and Q8 need them read backwards.

Why it works is worth one sentence in your own notes, because it is a two-line proof from the definition: any common divisor of a pair divides the remainder as well, since r = a − bq, and conversely — so each line has exactly the same set of common divisors as the line above it, and the process must end because the remainders strictly decrease and cannot go below zero.

Q5(a) is the same algorithm on a second pair, and Q5(b) then uses the identity relating a product to its gcd and lcm.

gcd(a, b) · lcm(a, b) = ab for positive a, b

Divide before you multiply: cancelling the gcd into one of the two numbers first keeps every intermediate value small, while forming the full product ab and then dividing is a long multiplication done for nothing.

Q5(c) is a definition question, not an algorithm question. One part has a negative entry and the other has a zero, and the algorithm as stated assumes neither. Go back to the sentence the question quotes — the largest positive integer dividing both — and settle each from two facts you can prove in a line: an integer d divides a exactly when it divides −a, and every integer divides 0, since 0 is that integer times zero. Decide what the common divisors of each pair therefore are, and take the largest positive one.

Bezout's identity and the extended algorithm

Q6 asks for gcd(391, 299) together with integers x and y satisfying 391x + 299y = gcd(391, 299). Producing the pair is the point: it is a certificate that can be checked in one multiplication, and it is what the next set turns into a modular inverse.

Back-substitution, line by line

Run the algorithm forwards, then walk it backwards.

  1. 1
    Do the divisions and keep them

    Exactly as in Q4. Number the lines so you can walk up them.

  2. 2
    Solve each line for its remainder

    From a = bq + r, write r = a − bq. Start at the line whose remainder is the gcd.

  3. 3
    Substitute upwards, collecting as you go

    Replace the smaller remainder in your expression using the line above, then collect the coefficients of the two numbers that appear. Never multiply out a coefficient you will need to collect — keep the two original numbers visible as symbols until the end.

  4. 4
    Check

    Multiply out 391x + 299y with your x and y. It costs one line and catches every sign slip, which is where this method goes wrong.

One of x and y is negative, always. If both were positive the combination would be at least as large as either number, and the gcd is not. So a negative coefficient is a sign the work is going right, not a sign of an error — and the pair is never unique, since adding a multiple of one number to x and subtracting the matching multiple from y gives another valid pair.

Q7 states Bezout's identity in its strong form: the integers expressible as ax + by are exactly the multiples of gcd(a, b). That single sentence answers both parts. For Q7(a), compute gcd(18, 42), ask whether the right-hand side is a multiple of it, and say which direction of the identity you are using — this is a proof of impossibility, so the argument must be that every value of 18x + 42y is divisible by that gcd, which follows directly from the definition of a common divisor.

For Q7(b) the same test passes, so a solution exists and the identity tells you how to build one: find a combination giving the gcd — by inspection here, since the numbers are small, or by the extended algorithm — and then scale the whole equation by the factor that turns the gcd into the required right-hand side. One solution is all that is asked; do not hunt for the general family.

The synthesis question

Q8 runs the whole set in two parts. Part (a) is Q4 and Q6 on one pair: the Euclidean algorithm for gcd(1309, 1001), then back-substitution to write it as 1309x + 1001y, then the one-line check.

Part (b) supplies the prime factorisation of 1001 and asks you to use the gcd to factor 1309. The gcd is a common divisor, so it comes out of 1309 as a factor; divide and decide whether what remains is prime, using the stopping rule from Q3(a) on a number now small enough to make that quick. Then the lcm follows from the same identity as in Q5(b), or by taking the larger exponent on each prime once both factorisations are written over the same primes — and the two routes agreeing is the check that ends the sheet.

A gcd found by an algorithm still has to be consistent with the factorisations. If the gcd from part (a) does not appear among the primes of 1001 that the question supplies, a division in the algorithm is wrong. Reconciling the two methods is the habit this question is built to teach.

Preview all 4 pages

Click any page to open the full PDF.

Page 1 of the University Discrete Math Divisibility and Primes practice worksheet
Page 1
Page 2 of the University Discrete Math Divisibility and Primes practice worksheet
Page 2
Page 3 of the University Discrete Math Divisibility and Primes practice worksheet
Page 3
Page 4 of the University Discrete Math Divisibility and Primes practice worksheet
Page 4

Getting the most out of it

Quote the definition before you compute

b | a means a = bk for some integer k; gcd is the largest positive common divisor. Most questions in this set are one substitution away from their definition, and the parts that ask "why" want the definition written out, not a number.

Keep every line of the algorithm

The Euclidean algorithm is run once and used twice — once forwards for the gcd, once backwards for the Bezout coefficients. Number your lines as you go. Recomputing them in Q6 and Q8 because they were scribbled over is the commonest waste of time on this sheet.

Check a certificate, do not admire it

Any claimed x and y can be verified in one multiplication, and any claimed factorisation can be verified by multiplying it back. These are the rare questions whose answers check themselves — use that on every one of them.

Watch the range of the remainder

0 ≤ r < b is not decoration. A negative dividend, a leftover below zero after regrouping, and a remainder left larger than the divisor are three versions of the same error, and each one turns a correct calculation into a wrong answer.

Work over one common list of primes

When two numbers are compared through their factorisations, write both over the same primes, giving an absent prime the exponent 0. Lined up in columns, gcd, lcm and the divisor count are all read off the same table instead of being recomputed from scratch.

Want the solutions, or something more challenging?

The worksheet, the questions above and every explanation on this page stay free permanently. Three more PDFs exist for this topic — the worked answer key, a harder problem set, and the answer key to that. They come with the University Discrete Math Solutions Bundle, beside the unit notes and the unit test, which is what keeps the rest of the series free.

What else exists for Divisibility and Primes

Three PDFs · 8 pages · all three are in the bundle below.

  • Answer key — 2 pages. All 8 questions worked step by step, including the restrictions and the justifications. Not a list of final answers.
  • Challenge problems — 4 pages, 5 problems. A separate sheet at exam-plus difficulty covering the same 4 concepts. Harder than anything on the free sheet.
  • Challenge answer key — 2 pages. Every challenge problem worked to the same standard, with the checks shown.
  • PDF, letter size, print-ready.
In the bundle See what's in it Not sold separately

The one thing that's for sale

Best value for the whole year

Every University Discrete Math topic — the complete Solutions Bundle

One download, one payment, the whole program. For all 9 University Discrete Math units: the worksheet, the reference notes, the challenge set, the unit test and every answer key — including this one.

9 units · 36 PDFs · 155 pages$24.99
  • Worked solutions, not answer lists — every step written out
  • Covers the whole year's program at this level
  • Less than the price of one hour of tutoring — for the entire year's solutions
Everything paid, in one file $24.99CAD · one payment University Discrete Math bundle — coming soon Not on sale yet

Taking Secondary 1 Math as well? The Secondary 1 Math bundle covers all 15 of its units — 106 PDFs, 474 pages — on the same terms.

Taking Secondary 2 Math as well? The Secondary 2 Math bundle covers all 14 of its units — 98 PDFs, 449 pages — on the same terms.

Taking Secondary 3 Math as well? The Secondary 3 Math bundle covers all 11 of its units — 77 PDFs, 367 pages — on the same terms.

Taking Secondary 4 Math as well? The Secondary 4 Math bundle covers all 17 of its units — 122 PDFs, 466 pages — on the same terms.

Taking Secondary 5 Math as well? The Secondary 5 Math bundle covers all 21 of its units — 147 PDFs, 589 pages — on the same terms.

Taking CEGEP Calculus I as well? The CEGEP Calculus I bundle covers all 9 of its units — 72 PDFs, 371 pages — on the same terms.

Taking CEGEP Calculus II as well? The CEGEP Calculus II bundle covers all 8 of its units — 64 PDFs, 335 pages — on the same terms.

Taking CEGEP Linear Algebra as well? The CEGEP Linear Algebra bundle covers all 7 of its units — 56 PDFs, 298 pages — on the same terms.

Taking University Calculus III as well? The University Calculus III bundle covers all 9 of its units — 72 PDFs, 516 pages — on the same terms.

Taking University Linear Algebra as well? The University Linear Algebra bundle covers all 9 of its units — 72 PDFs, 496 pages — on the same terms.

Taking University Differential Equations as well? The University Differential Equations bundle covers all 9 of its units — 36 PDFs, 182 pages — on the same terms.

Taking University Business Math as well? The University Business Math bundle covers all 9 of its units — 36 PDFs, 190 pages — on the same terms.

Taking University Introductory Statistics as well? The University Introductory Statistics bundle covers all 9 of its units — 36 PDFs, 186 pages — on the same terms.

Taking AP Calculus AB as well? The AP Calculus AB bundle covers all 8 of its units — 64 PDFs, 527 pages — on the same terms.

Common questions

Is this worksheet really free?

Yes — the questions are on this page to read, and the PDF downloads directly, no email and no account. The one paid item is optional: the complete University Discrete Mathematics Solutions Bundle, which covers every set at this level.

Which university courses is this for?

The course codes listed on this page are taken from the public course calendars of universities that teach discrete mathematics to mathematics, computer science and engineering students. Each course orders and weights the chapters its own way, and some reach a chapter late in the term or not at all — so check the outline for your own section to see where this set falls in your term.

What do I need to know before starting this set?

Secondary 5 algebra, handled fluently, and the proof habits of the earlier set Methods of Proof — a direct proof from a definition and a proof by contradiction. No calculus and no linear algebra are used anywhere in this set.

Why is the remainder never allowed to be negative?

Because that constraint is what makes the pair of quotient and remainder unique. Without 0 ≤ r < b, the same dividend could be written in infinitely many ways, and "the remainder" would not name a single number. It is also why b | a can be defined as the remainder being zero.

Why is it enough to test divisors up to the square root?

If a number factors as d times e with d the smaller, then d times d is at most the number, so d is at most its square root. Any composite number therefore has a divisor — and so a prime divisor — no larger than its square root, and finding none there proves there is none at all.

Why use the Euclidean algorithm when I could just factor both numbers?

Factoring is fine for the three- and four-digit numbers on this sheet and hopeless for the numbers used in cryptography, where the security rests on factoring being hard. The Euclidean algorithm takes a few dozen steps on numbers hundreds of digits long, which is why it, and not factoring, is what the next set is built on.

Are the Bezout coefficients unique?

No. Adding a multiple of one of the two numbers to x while subtracting the matching multiple from y produces another valid pair, so there are infinitely many. A question asking for integers x and y wants one pair, verified by substitution.

How do I know whether an equation like ax + by = c has an integer solution?

Compute gcd(a, b) and ask whether it divides c. The values of ax + by are exactly the multiples of that gcd, so the equation is solvable when the gcd divides c and impossible otherwise — one divisibility test settles it before any searching.

Can teachers use this in class?

Yes. Print and photocopy it for your own classes freely — I just ask that the tutorinmontreal.ca footer stays on the page.

I'm stuck on one question. Can you help?

Yes — through one-on-one tutoring, in Montreal or online. Get in touch to arrange a session, or see the current rates.

← All 9 University Discrete Math worksheets  ·  Secondary 1 Math series (15 sheets) →  ·  Secondary 2 Math series (14 sheets) →  ·  Secondary 3 Math series (11 sheets) →  ·  Secondary 4 Math series (17 sheets) →  ·  Secondary 5 Math series (21 sheets) →  ·  CEGEP Calculus I series (9 sheets) →  ·  CEGEP Calculus II series (8 sheets) →  ·  CEGEP Linear Algebra series (7 sheets) →  ·  University Calculus III series (9 sheets) →  ·  University Linear Algebra series (9 sheets) →  ·  University Differential Equations series (9 sheets) →  ·  University Business Math series (9 sheets) →  ·  University Introductory Statistics series (9 sheets) →  ·  AP Calculus AB series (8 sheets) →

Download the free worksheet

Ready to improve your grades?

WhatsApp is the way to reach me — tell me the course you're taking and what you're stuck on, and we'll sort out a first session from there.

Message Me on WhatsApp

or send a message

I reply within a day, usually sooner. Your details are used only to answer you — see the Privacy Policy.

Private math & science tutoring in Montreal, QC — Westmount · Outremont · Town of Mount Royal · Hampstead · Côte-Saint-Luc · NDG · Nuns' Island · West Island — and online across Quebec.

Chat with Marius