Skip over navigation
Cambridge University Faculty of Mathematics NRich logo
menu search
  • Teachers expand_more
    • Early years
    • Primary
    • Secondary
    • Post-16
    • Events
    • Professional development
  • Students expand_more
    • Primary
    • Secondary
    • Post-16
  • Parents expand_more
    • Early Years
    • Primary
    • Secondary
    • Post-16
  • Problem-Solving Schools
  • About NRICH expand_more
    • About us
    • Impact stories
    • Support us
    • Our funders
    • Contact us
  • search

Or search by topic

Number and algebra

  • The Number System and Place Value
  • Calculations and Numerical Methods
  • Fractions, Decimals, Percentages, Ratio and Proportion
  • Properties of Numbers
  • Patterns, Sequences and Structure
  • Algebraic expressions, equations and formulae
  • Coordinates, Functions and Graphs

Geometry and measure

  • Angles, Polygons, and Geometrical Proof
  • 3D Geometry, Shape and Space
  • Measuring and calculating with units
  • Transformations and constructions
  • Pythagoras and Trigonometry
  • Vectors and Matrices

Probability and statistics

  • Handling, Processing and Representing Data
  • Probability

Working mathematically

  • Thinking mathematically
  • Developing positive attitudes
  • Cross-curricular contexts

Advanced mathematics

  • Decision Mathematics and Combinatorics
  • Advanced Probability and Statistics
  • Mechanics
  • Calculus

For younger learners

  • Early Years Foundation Stage

Squaresearch

Age 14 to 16
Challenge Level Yellow starYellow starYellow star
  • Problem
  • Getting Started
  • Student Solutions

Pete Inglesby from Wolverhampton; Patrick Snow, age 16, Dame Alice Owens School, Potters Bar; Yatir Halevi, age 18, Maccabim-Reut High-School, Israel; Andrei Lazanu, age 12, School 205, Bucharest, Romania all solved this problem. Here is Pete's solution:

Consider numbers of the form

$$ u(n) = 1! + 2! + 3! +...+ n!. $$

How many such numbers are perfect squares?

In fact only when $n=1$ or $n=3$ does $u(n)$ give a perfect square ($1$ and $9$ respectively).

The solution lies in the fact that all factorials above $5!$ are multiples of $10$. This is because they all have $2$ and $5$ as prime factors. For $n> 5$

$$\eqalign { n!&=1 \times 2\times 3\times 4\times 5\times \cdots \times n \cr &= 2\times 5(1\times 3\times 4\times \cdots \times n) \cr &= 10(1\times 3\times 4\times \cdots n).}$$

When adding a multiple of $10$, to another integer, $k$, the last digit of $k$ will remain the same. Suppose $k = 10j + l$ and $m =10n$, with $l$ and $n$ integers, then $k + m = 10(j + n) + l$.

So when adding all factorials equal to or higher than $5!$ then you are adding a multiple of ten, so the last digit of the sum will be the same. This is important because the last digit of $u(4)$ is a $3$. We have $u(4) = 1! + 2! + 3! + 4! = 1 + 2 + 6 + 26 = 33$. Therefore for any $u(n)$ with $n> 5$ the last digit will be $3$. For any integer $p = (10a + b)$ with $a$ and $b$ integers and $b< 10$, $p^2 = (100a^2 + 20ab + b^2)$. Therefore the last digit is of $p^2$ is only dependent on $b^2$.
b b2 Last digit of b2
0 0 0
1 1 1
2 4 4
3 9 9
4 16 6
5 25 5
6 36 6
7 49 9
8 64 4
9 81 1

This table shows that the squares of all integers between $0$ and $9$, and therefore all integers, end in either $1$, $4$, $5$, $6$ or $9$.

No perfect squares end in $3$. Therefore, $u(n)$ with $n > 4$ can never be a perfect square as it has been shown to always end in $3$.

All that remains is to find $u(n)$ for all integers of $4$ or less:

$u(1) = 1! = 1$;
$u(2) = 1! + 2! = 3$;
$u(3) = 1! + 2! + 3! = 9$;
$u(4) = 1! + 2! + 3! + 4! = 33.$

Only $u(1)$ and $u(3)$ are perfect squares, and so they are the only sums of factorials to be perfect squares.


You may also like

N000ughty Thoughts

How many noughts are at the end of these giant numbers?

Factorial

How many zeros are there at the end of the number which is the product of first hundred positive integers?

Fac-finding

Lyndon chose this as one of his favourite problems. It is accessible but needs some careful analysis of what is included and what is not. A systematic approach is really helpful.

  • Tech help
  • Accessibility Statement
  • Sign up to our newsletter
  • Twitter X logo

The NRICH Project aims to enrich the mathematical experiences of all learners. To support this aim, members of the NRICH team work in a wide range of capacities, including providing professional development for teachers wishing to embed rich mathematical tasks into everyday classroom practice.

NRICH is part of the family of activities in the Millennium Mathematics Project.

University of Cambridge logo NRICH logo