
#challenge
💻 Pentagonal Number | #easy
Write a function that takes a positive integer num and calculates how many dots exist in a pentagonal shape around the center dot on the Nth iteration.
In the image below you can see the first iteration is only a single dot. On the second, there are 6 dots. On the third, there are 16 dots, and on the fourth there are 31 dots.
Return the number of dots that exist in the whole pentagon on the Nth iteration.
Examples:
#interview
💻 Pentagonal Number | #easy
Write a function that takes a positive integer num and calculates how many dots exist in a pentagonal shape around the center dot on the Nth iteration.
In the image below you can see the first iteration is only a single dot. On the second, there are 6 dots. On the third, there are 16 dots, and on the fourth there are 31 dots.
Return the number of dots that exist in the whole pentagon on the Nth iteration.
Examples:
pentagonal(1) ➞ 1🏆 Leave your solutions in the comments. The solution will be posted below in a couple of hours 👇
pentagonal(2) ➞ 6
pentagonal(3) ➞ 16
pentagonal(8) ➞ 141
#interview