FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaScript/Maths/HexagonalNumber.js at master · MMABSOUT/JavaScript · GitHub
MMABSOUT
/
JavaScript
Public
forked from
TheAlgorithms/JavaScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaScript
/
Maths
/
HexagonalNumber.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
21 lines (19 loc) · 679 Bytes
Breadcrumbs
JavaScript
/
Maths
/
HexagonalNumber.js
Copy path
File metadata and controls
21 lines (19 loc) · 679 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
* Author: Akshay Dubey (https://github.com/itsAkshayDubey)
* Hexagonal Number: https://en.wikipedia.org/wiki/Hexagonal_number
* The nth hexagonal number hn is the number of distinct dots in a pattern of dots
* consisting of the outlines of regular hexagons with sides up to n dots, when the
* hexagons are overlaid so that they share one vertex.
*/
/**
*
@function
hexagonalNumber
*
@description
-> returns nth hexagonal number
*
@param
{
Integer
} number
*
@returns
{
Integer
} nth hexagonal number
*/
export
const
hexagonalNumber
=
(
number
)
=>
{
if
(
number
<=
0
)
{
throw
new
Error
(
'Number must be greater than zero.'
)
}
return
number
*
(
2
*
number
-
1
)
}
Back
|
FazBrowse Home
|
New Git URL