All articles
10 min read

Cantor Set: How to Test Any Fraction With the 0-and-2 Rule

The Cantor set contains a number in [0,1] exactly when it has a base-3 expansion using only the digits 0 and 2. This page shows how to test any fraction.

By Sunil Bansal, Founder · Updated 16 Nov 2026

A student at a desk studies a paper strip while rows of strips with their middle thirds cut out are pinned on the wall behind her.

Key takeaways

  • A number in [0,1] is in the Cantor set if and only if it has a base-3 expansion using only the digits 0 and 2. The set is closed, compact, perfect, nowhere dense, totally disconnected, of measure 0 and uncountable.

  • Five steps decide any fraction. The only trap is a number with two expansions, such as 1/3, which is 0.1 in base 3 and also 0.0222… in base 3.
  • Survivors are not only endpoints. Among reduced fractions with denominator up to 200, 198 of 12,233 lie in the set and 166 of those are not endpoints (our count, November 2026).
  • Neither syllabus names the Cantor set; both list compactness, connectedness and Lebesgue measure (the standard way to assign a length to a set of real numbers).
In this article
  1. 1Is this number in the Cantor set? The 0-and-2 answer
  2. 2What the CSIR NET and GATE syllabi say
  3. 3A five-step test for any fraction
  4. 4What we found testing 4,387 fractions
  5. 5Four misconceptions that cost marks
  6. 6Why the Cantor set has measure zero
  7. 7Cantor set true or false checklist
  8. 8Where SBTech Math fits
  9. 9Frequently asked questions

Most students meet the Cantor set as a drawing: take the interval [0,1], remove the open middle third, and repeat on every piece that is left. Then a question arrives that the drawing cannot answer quickly. Is 1/4 in the set? Is 1/2? Is a point that was never an endpoint still there?

The drawing hides the fast route, which is arithmetic. Write the number in base 3 and read its digits. We checked that rule against the direct removal procedure on every reduced fraction with a small denominator, and the two methods never disagreed.

The same test settles a belief that costs marks: that only the endpoints of the removed intervals survive. They are not the only survivors. 1/4 is in the set and is not an endpoint.

Below you get the five-step test, what our counts show, four common mistakes, the measure-zero arithmetic and a true or false checklist. It is written for CSIR NET (Council of Scientific and Industrial Research National Eligibility Test) and GATE (Graduate Aptitude Test in Engineering) mathematics.

Is this number in the Cantor set? The 0-and-2 answer

A number x in [0,1] is in the Cantor set if and only if it has a base-3 expansion using only the digits 0 and 2. Base 3 means x = a₁/3 + a₂/9 + a₃/27 + …, with each digit aₙ equal to 0, 1 or 2.

The Cantor set, written C, has seven properties, each glossed here:

  • Closed: it contains all its limit points.
  • Compact: it is closed and bounded in the real line.
  • Perfect: it is closed and has no isolated points.
  • Nowhere dense: it is closed and contains no interval.
  • Totally disconnected (so not connected): every connected subset is a single point.
  • Measure 0: for any ε > 0, intervals of total length less than ε can cover it.
  • Uncountable: its points cannot be listed as a sequence.

The rule follows from the construction. C is what remains of [0,1] after deleting the open middle third (1/3, 2/3), then the open middle third of each remaining piece, forever. Deleting (1/3, 2/3) removes the numbers whose first base-3 digit must be 1. The second round removes those whose second digit must be 1, and so on.

What the CSIR NET and GATE syllabi say

Neither syllabus names the Cantor set. Both list the topics it illustrates, so it can appear as an example inside a question about those topics.

The CSIR-UGC NET common syllabus for Mathematical Sciences (Parts B and C), published by the CSIR Human Resource Development Group, lists under Unit 1:

  • "Elementary set theory, finite, countable and uncountable sets"
  • "Bolzano Weierstrass theorem, Heine Borel theorem"
  • "Lebesgue measure"
  • "Metric spaces, compactness, connectedness"

The GATE 2027 Mathematics (MA) syllabus, issued by IIT Madras as organising institute, lists in Section 3, Real Analysis:

  • "Metric spaces, Baire category theorem, connectedness, compactness, completeness"
  • "Lebesgue measure on the real line, measurable functions"

Heine–Borel (a subset of the real line is compact exactly when it is closed and bounded) is used in the checklist below. The Baire category theorem is quoted from the syllabus and is not used on this page.

Our recommendation is to learn the seven properties and the digit test rather than the drawing. A question that mentions the Cantor set can then be answered from the property list. For a topic-by-topic reading, see our CSIR NET Mathematical Sciences syllabus explained and our GATE MA syllabus topic list.

A five-step test for any fraction

To test a fraction for the Cantor set, write it in base 3 and check that no 1 survives. Five steps decide it.

Hands fold a paper strip into three equal parts and shade the middle third, with a pencil and ruler nearby.
Splitting the interval into thirds is the physical version of reading one base-3 digit at a time.
  1. 1
    Get the digits
    Multiply x by 3. The whole-number part is the next digit. Keep the fractional part and repeat.
  2. 2
    Find the shape of the expansion
    Stop when the fractional part is 0 (the expansion terminates) or when a fractional part comes back (the digits repeat from there). For a repeating expansion, note the pre-period (the digits before the repeat) and the repeating block.
  3. 3
    Pass if only 0s and 2s appear
    If every digit in the pre-period and the block is 0 or 2, x is in C.
  4. 4
    Rewrite a final 1
    If the only 1 is the last nonzero digit of a terminating expansion, rewrite it as 0 followed by repeating 2s, then retest. So 1/3 = 0.1₃ = 0.0222…₃ and 1/9 = 0.01₃ = 0.00222…₃, and both pass.
  5. 5
    Fail if any other 1 remains
    A 1 in the pre-period, in the repeating block, or anywhere other than the last place of a terminating expansion means x is not in C. Only terminating expansions have a second form, so there is nothing else to try.

Finally, check the denominator in lowest terms. If it is a power of 3, x is an endpoint of a removed interval. If not, x is a survivor that is not an endpoint.

FractionBase-3 expansionIn C?Why
1/40.0202…₃ (block 02)YesPre-period empty; the block uses only 0 and 2.
1/100.00220022…₃ (block 0022)YesThe block uses only 0 and 2.
1/130.002002…₃ (block 002)YesThe block uses only 0 and 2.
1/20.111…₃NoEvery digit is 1, and 1/2 does not terminate, so no second expansion exists.
1/3 (two expansions)0.1₃ = 0.0222…₃YesThe lone final 1 is rewritten as 0 then repeating 2s, which passes.

What we found testing 4,387 fractions

We tested every reduced fraction p/q in [0,1] with denominator up to 120, 0 and 1 included, 4,387 in total. We did this in November 2026 using exact fraction arithmetic in Python.

Each fraction went through two independent tests:

  • The base-3 digit rule above, with the second expansion allowed when the denominator is a power of 3.
  • Eighty rounds of the middle-third removal itself.

The two tests agreed on all 4,387 fractions. Counting with the digit rule alone, we then found how many reduced fractions in [0,1] lie in C at four denominator limits:

Denominator up toReduced fractionsIn CShare in CDenominator a power of 3 (endpoints)Not endpoints
10331442.4%86
50775587.5%1642
1003,0451163.8%3284
20012,2331981.6%32166

Two things stand out:

  • Most survivors are not endpoints. The smallest denominator where a survivor is not an endpoint is 4 (1/4). Up to denominator 100, the denominators that produce such fractions are 4, 10, 12, 13, 28, 30, 36, 39, 40, 82, 84, 90 and 91.
  • The share in C falls as the limit rises. This fits a set of measure 0. It is our reading of the counts, not a probability: the rationals are countable, so these counts show how the rule behaves, not how large C is.

The practical lesson is to run the test instead of guessing "yes". Most fractions fail, and the ones that pass need not be endpoints.

Four misconceptions that cost marks

Four wrong beliefs about the Cantor set account for most lost marks, and each has a short correction.

"Only the endpoints survive." The endpoints of the removed pieces do survive, but they are not the only points left. 1/4 = 0.0202…₃ is in C, and 1/4 has no form m/3ⁿ, so it is not an endpoint of any stage.

"The endpoints double each stage, so 2ⁿ becomes 2^∞ and the endpoints are uncountable." Each stage adds only finitely many endpoints, and a union of countably many finite sets is countable. Taking the limit of the numbers 2ⁿ does not give the size of the limiting set. The endpoints are all fractions m/3ⁿ, so they are countable. C is uncountable for a different reason: each infinite string of 0s and 2s names a different point, and such strings cannot be listed.

"The Cantor set is countably finite." Countable means finite or countably infinite, so "countably finite" is not a third category. C is none of these.

"The endpoints are countable, so the set is small, or countable too." The inference runs the other way. The endpoints are countable and C is uncountable, so uncountably many points of C are not endpoints. The fractions 1/4, 1/10 and 1/13 are three of the countably many rational ones.

Why the Cantor set has measure zero

The Cantor set has Lebesgue measure zero because the removed intervals have total length 1. Lebesgue measure assigns a length to a set, and a set has measure zero when intervals of arbitrarily small total length cover it. The removed lengths sum to:

1/3 + 2/9 + 4/27 + … = (1/3) ÷ (1 − 2/3) = 1

so what remains in [0,1] has length 1 − 1 = 0 (Rudin, Principles of Mathematical Analysis, 3rd ed., ch. 2, construction in 2.44).

The stage table gives the covers directly. At stage n the set is inside 2ⁿ closed intervals of length 3⁻ⁿ, with total length (2/3)ⁿ, which tends to 0.

Rows of paper ribbons on a table, each row with more middle thirds cut away and less ribbon left, with scissors beside them.
Each round of cutting removes a third of what is left, so the remaining length shrinks toward zero.
Stage nIntervals kept (2ⁿ)Length of each (3⁻ⁿ)Total length kept ((2/3)ⁿ)
0111
121/30.667
241/90.444
381/270.296
4161/810.198
5321/2430.132
6641/7290.088
101,0241/59,0490.0173

By our arithmetic, (2/3)ⁿ first drops below 0.01 at stage 12 and below 0.001 at stage 18.

Measure zero does not mean countable. Every countable set has measure zero, but C is uncountable and still has measure zero. Nowhere dense does not force measure zero either. If stage n removes 2ⁿ⁻¹ intervals of length 4⁻ⁿ, the removed lengths sum to 1/2 (the sum of 2ⁿ⁻¹/4ⁿ over n ≥ 1, our calculation). This set, called a fat Cantor set, is closed and nowhere dense but has measure 1/2.

Cantor set true or false checklist

Seven of the thirteen statements below are true and six are false, and each has a check you can run in your head or on paper.

StatementVerdictHow to check
The Cantor set is closedTrue

It is [0,1] minus a union of open intervals, so its complement in the real line is open.

The Cantor set is compactTrueIt is closed and bounded in the real line (Heine–Borel). Pass when both hold.
The Cantor set is perfectTrueClosed, and for any point p and ε > 0 pick n with 3⁻ⁿ < ε. The other endpoint of p's stage-n piece is in C and within ε.
The Cantor set is nowhere denseTrueIt is closed. An interval inside it would fit in one stage-n piece for every n, so its length would be 0.
The Cantor set is totally disconnectedTrue

A connected set with two points a < b contains [a, b], and C contains no interval.

The Cantor set is connectedFalse (it is totally disconnected)It contains two points but not the interval between them. 1/3 and 2/3 are in C, and 1/2 is not.
The boundary of the Cantor set is emptyFalse (the boundary is the set itself)C is closed, so its closure is C, and its interior is empty. Boundary = closure minus interior = C.
The Cantor set is countableFalseEach infinite 0-and-2 string is a distinct point, and those strings cannot be listed.
The Cantor set has measure zeroTrueChoose n with (2/3)ⁿ < ε, and the stage-n intervals cover it.
Every point of the Cantor set is an endpointFalse1/4 is in C and is not of the form m/3ⁿ.
A set of measure zero is countableFalseC has measure zero and is uncountable.
A nowhere dense closed set has measure zeroFalseThe fat Cantor set above is closed, nowhere dense and has measure 1/2.
1/3 is in the Cantor setTrue1/3 = 0.0222…₃ uses only 0 and 2 (the two-expansions case).

Where SBTech Math fits

We provide online mathematics preparation for CSIR NET, GATE, IIT JAM (Joint Admission Test for Masters) and CUET PG (Common University Entrance Test Postgraduate). Our Real Analysis - Master Course costs ₹2,899 as of November 2026. Our PDF Drive offers free CSIR NET maths PDF notes. To ask which of our courses suits your exam, use our contact form.

Prepare for CSIR NET and GATE with SBTech Math

To ask which of our courses suits your exam, use our contact form.
Contact SBTech Math

Frequently asked questions

No. The Cantor set is uncountable. Each infinite string of 0s and 2s gives a different point, and such strings cannot be listed. Only its endpoints, the fractions m/3ⁿ, are countable. It still has measure zero.
No. Neither syllabus names it, but both list compactness, connectedness and Lebesgue measure, which it illustrates.
No. The Cantor set is totally disconnected. It contains 1/3 and 2/3 but not 1/2, and any connected set containing two points would have to contain the whole interval between them. At stage n every surviving piece has length 3⁻ⁿ, so no interval fits.
No. Endpoints are fractions of the form m/3ⁿ, which are countable, while the Cantor set is uncountable. 1/4 = 0.0202…₃ is in the set and is not an endpoint. Our count found such fractions from denominator 4 upward.

Sources

  1. 1.Principles of Mathematical Analysis, 3rd ed., ch. 2 (construction of the Cantor set in 2.44; Exercise 2.19), Walter Rudin
  2. 2.The Cantor Set: A Brief Introduction, Dylan R. Nelson (undated PDF, a personal-page copy by the author)
  3. 3.CSIR-UGC National Eligibility Test (NET): Common Syllabus for Part B and C, Mathematical Sciences, CSIR Human Resource Development Group
  4. 4.GATE 2027 Mathematics (MA) Syllabus, IIT Madras, GATE 2027 organising institute
  5. 5.Our own check: all 4,387 reduced fractions in [0,1] with denominator up to 120 tested by base-3 long division and by 80 rounds of middle-third removal. The counts at denominator limits 10, 50, 100 and 200 use the base-3 rule alone, in Python with exact fractions., November 2026

Keep reading

SBTechMath.

India's trusted Mathematics learning platform for CSIR-NET, GATE, IIT-JAM, CUET PG, and competitive exam aspirants. Learn concepts that help you succeed.

© 2026 SBTech Math

Powered by PageLens.ai

Crack CSIR-NET, GATE & IIT-JAM with concept-first learning.

Start Now