pentagonal number sequence
This commit is contained in:
parent
1b4ef0276b
commit
2ac37ad567
@ -28,3 +28,11 @@ def triangular(n: int) -> int:
|
|||||||
0, 1, 3, 6, 10, 15, ...
|
0, 1, 3, 6, 10, 15, ...
|
||||||
"""
|
"""
|
||||||
return n * (n + 1) // 2
|
return n * (n + 1) // 2
|
||||||
|
|
||||||
|
|
||||||
|
def pentagonal(n: int) -> int:
|
||||||
|
"""
|
||||||
|
A pentagonal number is a figurate number that extends the concept of triangular and square numbers to the pentagon
|
||||||
|
0, 1, 5, 12, 22, 35, ...
|
||||||
|
"""
|
||||||
|
return ((3 * n * n) - n) / 2
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user