Polygonal Number Calculator

P(s,n) = n((s−2)n−(s−4))/2

CalculatorsFreeNo Signup
4.8(413 reviews)
All Tools

Loading tool...

About Polygonal Number Calculator

A polygonal number calculator computing P(s,n) = n((s−2)n−(s−4))/2 for any number of sides s≥3. Generates sequences, tests membership, and finds which polygonal sequences contain a given number. All client-side.

Polygonal Number Calculator Features

  • Compute P(s,n)
  • Test membership
  • Sequence
  • Multi-polygon
  • Formula
Polygonal numbers: P(s,n) = n((s−2)n−(s−4))/2. Triangular P(3,n)=n(n+1)/2, Square P(4,n)=n², Pentagonal P(5,n)=n(3n−1)/2, Hexagonal P(6,n)=n(2n−1). Fermat's polygonal number theorem: every positive integer is sum of at most s s-gonal numbers.

How to Use

Enter s (sides) and n (index):

  • P(s,n): The nth s-gonal number
  • Test: Is m an s-gonal number?
  • Sequence: First N values

Common Types

  • Triangular (s=3): 1,3,6,10,15,21...
  • Square (s=4): 1,4,9,16,25...
  • Pentagonal (s=5): 1,5,12,22,35...
  • Hexagonal (s=6): 1,6,15,28,45...

Fermat's Theorem

Every positive integer is the sum of at most s s-gonal numbers. For triangulars: at most 3 (Gauss's eureka theorem). For squares: at most 4 (Lagrange). For pentagons: at most 5 (Cauchy).

Step-by-Step Instructions

  1. 1Choose s (sides).
  2. 2Enter n.
  3. 3Get P(s,n).
  4. 4Test membership.
  5. 5View sequence.

Polygonal Number Calculator — Frequently Asked Questions

What is Fermat's polygonal number theorem?+

Every positive integer is the sum of at most s s-gonal numbers. Proved by Cauchy (1813). Special cases: 3 triangulars (Gauss, 1796), 4 squares (Lagrange, 1770), 5 pentagonals, etc. Some need fewer: every n≥28 is sum of ≤5 pentagons.

How to test if m is an s-gonal number?+

Solve P(s,n)=m for n: n = ((s−4)+√((s−4)²+8(s−2)m))/(2(s−2)). If n is a positive integer, then m is s-gonal. For triangulars: n=(−1+√(1+8m))/2. For squares: n=√m.

Are there numbers that are polygonal for many s?+

1 is s-gonal for all s. Beyond 1, numbers that are simultaneously triangular, square, and pentagonal are extremely rare. The smallest is 1. The sequence of such multi-polygonal numbers grows very rapidly.

Share this tool: