polygonal

A simple library to get polygonal numbers

Usage no npm install needed!

<script type="module">
  import polygonal from 'https://cdn.skypack.dev/polygonal';
</script>

README

polygonal

NodeJs module for getting polygonal numbers

The Polygonal Numbers

Polygonal numbers are numbers that can be arranged in a regular polygon if they're represented as dots.

eg.:

triangular numbers

Triangular numbers

Formula

The formula to get the nth polygonal number of a s-sided polygon is:

polygonal formula

Installation

This module is on the npm repository, to intall it run the following command

$ npm install polygonal

Usage

var polygonal = require('polygonal');

// get the second pentagonal
var x = polygonal.getSGonal(5, 2);
var y = polygonal.getPentagonal(2);

// x is equal to y!!

References

http://en.wikipedia.org/wiki/Polygonal_number