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.

Solution: Pentagonal numbers

Solution: Pentagonal numbers - Visual Basic Tutorial

From the course: Visual Basic Essential Training

Start my 1-month free trial

Solution: Pentagonal numbers

(upbeat music) - Welcome back. How did you make out with that last challenge? Let me show you my solution, and remember it might be different from yours. I wrote it as a console application. So, you type in the number of rings. Press the enter key, and it gives you back this text, "ring count equals two. Total dots are six". Try for five, I get fifty one dots. You can use large numbers too. So, I wrote two versions of this function. I wrote the pentagonal dot counter, and I also did the generalized dot counter. Let me show you what that one looks like. This is for a rectangle. So if I type in two rings, I get back five. And five rings, I get back forty one. So here's how I wrote the code. I created a function called pentagonal dot counter, and another one called generalized dot counter, and here's the problem were trying to solve. We're adding one plus five plus ten plus fifteen. This should be twenty. So…

Contents