Any number can be written in any base b≥2 by repeated division, and its digits are remainders. A digit problem becomes algebra once you write abc=100a+10b+c
Lesson 3 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
What you will be able to do
write a number in base b and back, and count its digits;
turn a digit puzzle into an equation;
prove that a number is not a square or a cube from its remainders, or by placing it between two consecutive squares.
Counting in other bases
We count in tens because we have ten fingers. A computer counts in twos. In base b, a number with digits dk…d1d0, each from 0 to b−1, means
dkbk+⋯+d1b+d0.
We write the base as a small number below: 1011012=32+8+4+1=45.
To convertn into base b, divide by b again and again. The remainders, read from the last to the first, are the digits. For 1234 in base 7:
1234=7×176+2, so the units digit is 2.
176=7×25+1, so the next digit is 1.
25=7×3+4, and then 3=7×0+3.
So 1234=34127. Check: 3×343+4×49+1×7+2=1234.
The number of digits. A number N≥1 has k digits in base 10 exactly when 10k−1≤N<10k. So it has ⌊log10N⌋+1 digits. In base b use logbN instead.
Digit puzzles
Name the digits and write the number as a sum. A two-digit number is ab=10a+b.
ab−ba=9(a−b), always a multiple of 9.
abc−cba=99(a−c), a multiple of 99.
Worked example. A two-digit number is 4 times the sum of its digits. Find all such numbers.
Set up.10a+b=4(a+b), so 6a=3b, which gives b=2a.
List.a from 1 to 4 keeps b a digit: 12,24,36,48.
Check.36=4×9 and 3+6=9.
What squares can and cannot be
The last digit of n2 depends only on the last digit of n. Squaring 0 to 9 gives last digits 0,1,4,9,6,5,6,9,4,1. So a square never ends in 2, 3, 7 or 8.
Remainders tell even more. Sorting n by its remainder, as in course 1:
Divide by
A square leaves
A cube leaves
3
0,1
0,1,2
4
0,1
0,1,3
8
0,1,4
0,1,3,5,7
9
0,1,4,7
0,1,8
A bar chart of the remainders 0 to 8 on division by 9. Blue bars show how many of the squares of 0 to 899 leave each remainder; only 0, 1, 4 and 7 have bars. Orange bars show the same for cubes; only 0, 1 and 8 have bars. The other remainders have no bar at all.
Examples of use.
22,222,2222,… are never squares. Each leaves remainder 2 on division by 4, because its last two digits are 22.
A number whose digit sum is 3 more than a multiple of 9 is never a square or a cube. Its remainder on division by 9 is 3, and neither column contains 3.
The sum of three cubes leaves 0,1,2,3,6,7 or 8 on division by 9, never 4 or 5.
Squeezing between squares
There is no square strictly between m2 and (m+1)2. So if you can show
m2<N<(m+1)2,
then N is not a square.
Example. For n≥1, n2<n2+n+1<n2+2n+1=(n+1)2. So n2+n+1 is never a square for n≥1.
When the squeeze has gaps, factorise. Find all n≥1 with n2+6n+20 a square m2. Write it as (n+3)2+11=m2, so (m−n−3)(m+n+3)=11. As 11 is prime and m+n+3>0, the factors are 1 and 11. Then m=6 and n=2. Check: 4+12+20=36.
Practise with new numbers
Try it in Python
The program converts numbers into other bases and lists the remainders of squares and cubes, which fill the table above.
Common mistakes
Writing ab as ab. It means 10a+b, not a×b.
Reading the base-b digits in the wrong order. The first remainder is the units digit.
Using one remainder test only. A number may pass the test for 4 and fail the one for 9. Try several.
Squeezing with a loose bound. Check that both inequalities hold for every n in your range, and test the small n by hand.
Remember these
In base b, the digits are the remainders of repeated division by b.
A number N≥1 has ⌊log10N⌋+1 digits.
abc−cba=99(a−c).
Squares leave 0,1 on division by 4 and 0,1,4,7 on division by 9; cubes leave 0,1,8 on division by 9.
There is no square strictly between m2 and (m+1)2.
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
Write 100 in base 3.
How many digits does 230 have? Use log102≈0.30103.
Can a square end in the digits …7?
Show that n2+3n+3 is never a square for n≥1.
A number has digit sum 2003. Can it be a perfect cube?
References
David M. Burton, Elementary Number Theory, Chapter 4, section 4.3 on number bases and the remainders of squares.
Arthur Engel, Problem-Solving Strategies, Chapter 6 on number theory, for squares, digits and bounding.
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.