From the course: Visual Basic Essential Training

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Challenge: Pentagonal rings

Challenge: Pentagonal rings

(soft swelling music) - [Instructor] For this challenge, you'll code a classic problem. You can use a loop to solve this problem. It's the Pentagonal Ring Puzzle. Imagine a ring of points around the center point. We'll start with square rings. So we start with the center point, and then we draw a square with four points. So now we're going to count the number of points. We have one point in the center, and we have four points in the first square, so that gives us five. Then we add another square with three points on each side. That has eight points, so we add eight plus five. That gives us 13, and we keep doing this. The next ring has 12 points in it, so that's 12 plus 13 equals 25. So we keep doing this. We can do this with any shape. For example, this is how it works with a pentagon. For the first ring, there is one dot. Then the second ring has five dots. The third ring has 10 dots, and the fourth ring has 15 dots. Your challenge is to write a function that calculates the total dot…

Contents