Does the series converge or diverge? Alternating series, like the HailStone series always captivated my interests when studying calculus. A HailStone Series is defined as follows:
Start with any integer bigger than 0. If the integer is even, the next value in the series is half the original integer. If the integer is odd, the next value is three times the integer plus one. Apply the same rules to create the next value in the series…
For example, below is the HailStone Series generated by a starting value of 22.
When a Hailstone Series reaches the value of 1, it has converged; the next values will be 4, then 2, then 1.
Why I am so intrigued in HailStone series is because there is no formal proof that this series converges; it is a huge mathematical dilemma!
For my CSE 2112 (Excel) Lab, I was tasked to write a VBA (Visual Basic for Applications) program that allows users to enter a starting value from which the program computes and outputs the corresponding Hailstone series stopping with 1. This lab presented a huge challenge: I had never written a program in VBA language before. In fact, before I began taking this CSE class, I didn’t realize you could formally code in Excel. When beginning to work with VBA, I liked how visual it was. Unlike my previous coding experience in MatLab and C/C++, VBA was visual and easy to understand. For example, specific code was assigned to buttons and userforms.
Below are pictures of my code, and final output of the result.
The user is prompted to enter a number into the HailStone Series box, then presses the converge button to create the list highlighted in yellow. Each step to convergence, or calculation, is on the left column, while the number of iterations, or amount of times a calculation is performed is in the right column.
One of the most difficult aspects to this lab was the formatting; I had never coded in the VBA language, so it was difficult to format the Excel spreadsheet to include borders, change text colors, and cell colors. The actual code wasn’t too difficult; the general calculation consisted of a if statement embedded in a while loop.
This lab got me excited and passionate about coding. In the past, I didn’t have great experiences coding, but this lab has changed my mind. I will definitely take more computer programming classes in the future!