Squares and cubes

Grow a square out of odd-numbered L-shapes and a cube out of unit cubes. Test any number for being a perfect square or cube from its prime factors, find the smallest number that makes it one, and hunt numbers like 1729 that are a sum of two cubes in two ways.

Keep it one tap away for everyday use.

Bookmark Squares and cubes?

Press Ctrl + D now. Your browser opens its own bookmark box, where you choose the name and folder.

  1. Pick n
  2. Build it
  3. Test number
  4. Check
Nothing is uploadedWorks offline once open
Build
n

Is it a perfect square or cube?

Taxicab numbers

1729 is the smallest number that is a sum of two cubes in two different ways. Find more, or test your own number.

Try this

  • Build a square and count the coloured L-shapes. Each one is an odd number: 1, 3, 5, ... Why does adding them always give a square?
  • Look at the last column of the table: squares only end in 0, 1, 4, 5, 6 or 9. So can 2,023 be a square?
  • Switch to Cube and press + 1. How many new cubes wrap round the old one? Check 3n² − 3n + 1.
  • Type 1008 above. What is the smallest number you must multiply it by to get a perfect square? And a perfect cube?
  • Press Next taxicab number a few times. Are they all even? All odd?

Check yourself

Fresh questions every time. Nothing is saved.

What it does

A square number is what you get when you lay unit squares out in an n × n square: n² of them. A cube number is what you get when you stack unit cubes into an n × n × n cube: n³ of them. This page builds both so you can see them grow.

The square is coloured in L-shapes: 1 square in the corner, then 3 round it, then 5, then 7… Each L is the next odd number, which is why 1 + 3 + 5 + … + (2n − 1) = n². The cube shows n layers of n² cubes, and how many new cubes wrap round it each time it grows by one: 3n² − 3n + 1.

Below the builder, type any number to see its prime factors and whether it is a perfect square (every prime comes in pairs) or a perfect cube (every prime comes in threes), which squares or cubes it sits between, and the smallest number to multiply or divide by to make it one. The last card hunts taxicab numbers, such as 1729 = 1³ + 12³ = 9³ + 10³, the number Ramanujan famously spotted in a taxi’s number plate.

It follows Class 8 Maths, a square and a cube (square numbers and their patterns, square roots by prime factorisation, cubes and cube roots, perfect cubes, the Hardy–Ramanujan number) and helps with powers in later classes. For prime factor trees, open HCF and LCM; for squares built from tiles in algebra, try the algebraic identity tiles; and for square numbers in right triangles, the pythagoras proof playground playground.

How to use it

  1. Pick Square or Cube, then set n from 1 to 12 with the slider, the box or the − 1 and + 1 buttons.
  2. Read the big line, the odd-number sum (square) or layers and shell (cube), and the table of n, n², n³ and the last digit of n² around your n.
  3. Under Is it a perfect square or cube?, type any whole number up to a billion.
  4. Under Taxicab numbers, press Next taxicab number, or type any number to see every way it can be written as a sum of two cubes.

Worked example

With n = 5, the square shows 1 + 3 + 5 + 7 + 9 = 25 = 5², and going from 4² to 5² adds one L of 9 squares: 16 + 9 = 25. Switch to Cube: 5 layers of 25 make 125, and growing from 4³ to 5³ wraps a shell of 3 × 25 − 3 × 5 + 1 = 61 cubes: 64 + 61 = 125.

The number box starts at 1008 = 2⁴ × 3² × 7. The 7 has no partner, so 1008 is not a perfect square: it lies between 961 = 31² and 1024 = 32². Multiply by 7 to get 7056 = 84², or divide by 7 to get 144 = 12². For a perfect cube you need 2⁶ × 3³ × 7³, so multiply by 2² × 3 × 7² = 588 to get 592,704 = 84³.

Check yourself

Five fresh questions: a square, a cube, the sum of the first odd numbers, a cube root and the smallest multiplier for a perfect square. Nothing is saved.

Tips

  • A square never ends in 2, 3, 7 or 8, and a number ending in an odd count of zeros cannot be a square either.
  • The square of an even number is even; the square of an odd number is odd. The same goes for cubes.
  • To find a square root by prime factors, pair up equal primes and take one from each pair.

FAQ

Why only up to n = 12? Beyond that the unit squares and cubes get too small to see on a phone. The number tester goes up to a billion.

Is 1729 really the smallest taxicab number? Yes, using positive cubes. With negative cubes allowed, 91 = 6³ + (−5)³ = 4³ + 3³ is smaller.

Is this from the NCERT book? It covers the same topics with fibub’s own pictures and examples. fibub is not part of NCERT.

Where the numbers come from

  • Squares and cubes, the sum of the first n odd numbers n², n³ − (n − 1)³ = 3n² − 3n + 1, perfect powers from prime factorisation, and the taxicab number 1729 (Hardy and Ramanujan) are standard number facts. Wording, pictures and examples are fibub's own.
  • Taxicab numbers checked against a brute-force Python search (1729, 4104, 13832, 20683, 32832, 39312, 40033, 46683 below 50,000) and OEIS A001235.

Standard scientific values, such as constants, atomic weights and melting points, are facts found in every textbook; we name where ours were checked. If you are an author or publisher and want a value, a credit or a table changed or removed, tell us and we will act quickly.

Last updated 2026-11-09.

Change log for Squares and cubes

  1. Add #1229 Square and cube builder Details on GitHub

Every change to fibub

Related tools

Number theory toolkit #T372 Test whether a huge number is prime, factorise it, find gcd and lcm with the extended Euclid table, work out modular powers and inverses, solve Chinese remainder systems, and expand continued fractions with their convergents. Exact whole-number arithmetic, in your browser. Pythagoras proof playground #L69 Drag a right triangle and watch the squares on its sides add up. Slide through four visual proofs (rearrangement, Bhaskara, similar triangles, Baudhayana) with your own side lengths, and list Pythagorean triples. HCF and LCM #L72 Type two numbers and watch their prime factor trees grow. Shared primes land in the middle of a Venn picture to give the HCF; all of them give the LCM. Euclid's division steps and the HCF × LCM check are shown too. Algebraic identity tiles #L75 See each algebraic identity as a picture: slide a and b and the square or rectangle splits into its pieces with the identity filled in. Watch a² − b² turn into (a + b)(a − b), and pull the cube (a + b)³ apart into eight blocks. Square root finder #L117 Type a number and find its square root four ways with every step shown: pair up prime factors (with the simplest surd form), subtract odd numbers, estimate between two squares and improve the guess, or use the long division method for decimals. Quadratic explorer #L68 Slide a, b and c and watch the parabola move: vertex, roots and the discriminant update live, completing the square is drawn with tiles, and the middle term is split for you. With fresh practice questions.