From the course: Visual Basic Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Challenge: Pentagonal numbers

Challenge: Pentagonal numbers - Visual Basic Tutorial

From the course: Visual Basic Essential Training

Start my 1-month free trial

Challenge: Pentagonal numbers

(upbeat music) - [Instructor] For this challenge, you'll code a classic for-loop problem. It's called the pentagonal numbers problem. The idea is to count the number of dots in a pentagon ring. For the first ring, there is one dot, the second ring has five dots, the third ring has 10 dots, and the fourth ring has 15. The challenge for you is to write a function to calculate the total dot count for any size shape. For example, when there are four rings, the total dots is 31. For six rings, the total is 76. Use a loop to calculate the total. You can built your app as a console or as a WPF application. Once you get the basic algorithm working, think about how you could alter it to work with other shapes. For example, with a rectangle, you'd have four dots in the second ring. In a hexagon, you'd have six. Create another function that works for any shape. Take your time to determine how to build the project. If you're…

Contents