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
  • Earth and Environmental Science
  • 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
Factorials, Irrational Numbers, Digits and the Floor Function
  1. 1The floor function and Legendre's formula
  2. 2Rational and irrational numbers
  3. 3Digits, bases, squares and cubes
  1. Mathematics
  2. /Factorials, Irrational Numbers, Digits and the Floor Function
  3. /Rational and irrational numbers

Course 27.3·Lesson 2 of 3

Rational and irrational numbers

A rational number is a fraction p/qp/qp/q of integers with q≠0q \ne 0q=0

Lesson 2 of 3Show all lessonsHide
Factorials, Irrational Numbers, Digits and the Floor Function
  1. 1The floor function and Legendre's formula
  2. 2Rational and irrational numbers
  3. 3Digits, bases, squares and cubes

Try the code and the simulations beside the lesson.

What you will be able to do

  • decide when a fraction has an ending decimal, and turn a repeating decimal into a fraction;
  • prove that 2\sqrt{2}2​, p\sqrt{p}p​, n\sqrt{n}n​ for a non-square nnn, and log⁡23\log_2 3log2​3 are irrational;
  • use the rational root theorem, and decide whether a sum or product of irrational numbers is rational.

Can the diagonal be measured?

A square has a side of 111 m. Its diagonal is 2\sqrt{2}2​ m long. The Greeks believed at first that any two lengths could be measured with a common unit, small enough. The diagonal and the side cannot. In number language, 2\sqrt{2}2​ is not a fraction.

Rational numbers and their decimals

A number is rational when it can be written pq\dfrac{p}{q}qp​ with integers ppp and qqq and q≠0q \ne 0q=0. Otherwise it is irrational.

When does a decimal end? Write the fraction in lowest terms. The decimal ends exactly when the denominator has no prime factor other than 222 and 555. For example, 740=7×2540×25=1751000=0.175\dfrac{7}{40} = \dfrac{7 \times 25}{40 \times 25} = \dfrac{175}{1000} = 0.175407​=40×257×25​=1000175​=0.175, since 40=23⋅540 = 2^3 \cdot 540=23⋅5. If q=2i5jq = 2^i 5^jq=2i5j, the decimal ends after the larger of iii and jjj places.

Otherwise it repeats. In the long division of ppp by qqq only the remainders 1,…,q−11, \dots, q - 11,…,q−1 can appear, so a remainder comes back, and from then on the digits repeat. For example 17=0.142857‾\dfrac{1}{7} = 0.\overline{142857}71​=0.142857, with a block of 666 digits.

From a repeating decimal to a fraction. Let x=0.27‾=0.2727…x = 0.\overline{27} = 0.2727\dotsx=0.27=0.2727…. Then 100x=27.2727…100x = 27.2727\dots100x=27.2727…, and 100x−x=27100x - x = 27100x−x=27. So x=2799=311x = \dfrac{27}{99} = \dfrac{3}{11}x=9927​=113​. In the same way 0.16‾=160.1\overline{6} = \dfrac{1}{6}0.16=61​.

So every rational number has an ending or repeating decimal, and every such decimal is rational. An irrational number has a decimal that goes on forever without repeating.

The square root of 2 is irrational

Proof. Suppose 2=pq\sqrt{2} = \dfrac{p}{q}2​=qp​ in lowest terms, so ppp and qqq share no factor.

  1. Squaring gives p2=2q2p^2 = 2q^2p2=2q2. So p2p^2p2 is even, and hence ppp is even (an odd number has an odd square).
  2. Write p=2kp = 2kp=2k. Then 4k2=2q24k^2 = 2q^24k2=2q2, so q2=2k2q^2 = 2k^2q2=2k2, and qqq is even too.
  3. Now ppp and qqq share the factor 222. That contradicts lowest terms. So 2\sqrt{2}2​ is irrational.
A right triangle with two legs of length 1 and the hypotenuse labelled square root of 2. Beside it the proof is written in three short lines: if p squared = 2 q squared then p is even; write p = 2k, then q squared = 2 k squared, so q is even; both even contradicts lowest terms.

The general case. Let nnn be a positive integer that is not a perfect square. Suppose n=pq\sqrt{n} = \dfrac{p}{q}n​=qp​. Then p2=nq2p^2 = nq^2p2=nq2. In p2p^2p2 and q2q^2q2 every prime has an even exponent. Since nnn is not a square, some prime has an odd exponent in nnn, and so an odd exponent in nq2nq^2nq2. By the fundamental theorem the two sides cannot be equal. So n\sqrt{n}n​ is irrational unless nnn is a perfect square. The same argument shows that 23\sqrt[3]{2}32​ is irrational.

Logarithms

log⁡23\log_2 3log2​3 is irrational. Suppose log⁡23=ab\log_2 3 = \dfrac{a}{b}log2​3=ba​ with positive integers aaa and bbb. Then 2a/b=32^{a/b} = 32a/b=3, so 2a=3b2^a = 3^b2a=3b. The left side is even and the right side is odd. That is impossible.

The rational root theorem

Theorem. If pq\dfrac{p}{q}qp​, in lowest terms, is a root of anxn+⋯+a1x+a0a_n x^n + \dots + a_1 x + a_0an​xn+⋯+a1​x+a0​ with integer coefficients, then p∣a0p \mid a_0p∣a0​ and q∣anq \mid a_nq∣an​.

Proof. Put x=p/qx = p/qx=p/q and multiply by qnq^nqn: anpn+an−1pn−1q+⋯+a0qn=0a_n p^n + a_{n-1}p^{n-1}q + \dots + a_0 q^n = 0an​pn+an−1​pn−1q+⋯+a0​qn=0. Every term except the last has a factor ppp, so p∣a0qnp \mid a_0 q^np∣a0​qn. As ppp and qqq share no prime, p∣a0p \mid a_0p∣a0​. In the same way q∣anpnq \mid a_n p^nq∣an​pn, so q∣anq \mid a_nq∣an​.

This gives a second proof for 2\sqrt{2}2​: it is a root of x2−2x^2 - 2x2−2, whose only possible rational roots are ±1\pm 1±1 and ±2\pm 2±2, and none of them works.

A harder one. Is 2+3\sqrt{2} + \sqrt{3}2​+3​ rational? Let x=2+3x = \sqrt{2} + \sqrt{3}x=2​+3​. Then x2=5+26x^2 = 5 + 2\sqrt{6}x2=5+26​, so (x2−5)2=24(x^2 - 5)^2 = 24(x2−5)2=24, that is, x4−10x2+1=0x^4 - 10x^2 + 1 = 0x4−10x2+1=0. The only possible rational roots are ±1\pm 1±1, and 1−10+1≠01 - 10 + 1 \ne 01−10+1=0. So xxx is irrational.

Sums and products

  • Rational plus irrational is irrational. If r+sr + sr+s were rational, so would be s=(r+s)−rs = (r + s) - rs=(r+s)−r.
  • A non-zero rational times an irrational is irrational, in the same way.
  • Two irrationals can give a rational: 2+(−2)=0\sqrt{2} + (-\sqrt{2}) = 02​+(−2​)=0 and 2×8=4\sqrt{2} \times \sqrt{8} = 42​×8​=4.

Practise with new numbers

Try it in Python

The program prints the length of the repeating block of 1n\dfrac{1}{n}n1​, turns 0.27‾0.\overline{27}0.27 into a fraction, and searches for whole numbers with p2=2q2p^2 = 2q^2p2=2q2.

Read it first. Then run it. Which fractions have a repeating block of length 000, and why?

1. Change range(2, 21) to range(2, 60). Which nnn give the longest blocks?

2. Change 2 * q * q to 3 * q * q and 2 ** 0.5 to 3 ** 0.5. Is the list still empty?

Common mistakes

  • Testing a fraction that is not in lowest terms. 312\dfrac{3}{12}123​ ends (0.250.250.25), though 121212 has the factor 333. Cancel first.
  • Saying "p2p^2p2 even, so ppp even" without a reason. An odd number squared is odd, so an even square has an even root.
  • Thinking the sum of two irrationals is irrational. It can be rational.
  • Using the rational root theorem on a polynomial with fractions. Clear the denominators first.

Remember these

  • pq\dfrac{p}{q}qp​ in lowest terms ends exactly when q=2i5jq = 2^i 5^jq=2i5j, after the larger of iii and jjj places.
  • Rational numbers have ending or repeating decimals.
  • n\sqrt{n}n​ is irrational unless nnn is a perfect square.
  • log⁡23\log_2 3log2​3 is irrational because 2a=3b2^a = 3^b2a=3b is impossible.
  • A rational root p/qp/qp/q of an integer polynomial has p∣a0p \mid a_0p∣a0​ and q∣anq \mid a_nq∣an​.

Check yourself

Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.

  1. Write 0.45‾0.\overline{45}0.45 as a fraction in lowest terms.
  1. Does 13160\dfrac{13}{160}16013​ have an ending decimal? After how many places?
  1. Prove that 5\sqrt{5}5​ is irrational.
  1. Is 12\sqrt{12}12​ rational?
  1. Prove that log⁡35\log_3 5log3​5 is irrational.

References

  • Ivan Niven, Numbers: Rational and Irrational, Chapters 2 and 4 on decimals and irrational numbers.
  • NCERT, Mathematics Textbook for Class X, Chapter 1 (Real Numbers), for the proof that 2\sqrt{2}2​ is irrational.

Enroll free in Factorials, Irrational Numbers, Digits and the Floor Function

Every lesson is open to read. Enrolling also lets you:

  • Mark lessons done and carry on where you stopped.
  • Take the tests of this lesson and its course.
  • Count the course towards the certificate for its chapter.
No payment. You can leave at any time.

Problems (3)

Prove that √3 is irrational. Show that x = √2 + √3 is a root of P(x) = x⁴ - 10x² + 1…Hard · High School (11–12) · by StemPy Lab
Prove that log₁₀ 2 is irrational. Using log₁₀ 2 = 0.30103 to five places, find the number of digits…Advanced · High School (11–12) · by StemPy Lab
Prove that 1/n has an ending decimal exactly when n = 2ⁱ 5ʲ…Advanced · High School (11–12) · by StemPy Lab
Next: lesson 3Digits, bases, squares and cubes
← Factorials, Irrational Numbers, Digits and the Floor Function
← The floor function and Legendre's formulaDigits, bases, squares and cubes →

Discussion (0)

Log in to join the discussion.

Loading…

. Its decimal either ends or repeats, and it ends exactly when the denominator in lowest terms has no prime other than
222
and
555
. Using the fundamental theorem,
n\sqrt{n}n​
is irrational unless
nnn
is a perfect square. The same method proves that numbers such as
log⁡23\log_2 3log2​3
and
2+3\sqrt{2} + \sqrt{3}2​+3​
are irrational, and the rational root theorem finds every possible rational root of a polynomial.
about 25 min1 simulation1 practice question1 Python program5 questions to check yourself

This lesson is free to read. Enroll free to keep your place and take the tests.