VERSION 2.00 Begin Form Form1 Caption = "Form1" ClientHeight = 4170 ClientLeft = 1020 ClientTop = 1425 ClientWidth = 7305 Height = 4575 Left = 960 LinkTopic = "Form1" ScaleHeight = 4170 ScaleWidth = 7305 Top = 1080 Width = 7425 End 'program Collatz 'Generates the Collatz sequence of an integer: if it 'is odd multiply it by 3 and add 1; if it is even 'divide it by 2; continue until 1 results. Sub Form_Click () Cls 'clear form n = 1 x = CInt(InputBox("Enter an integer:")) Print "Here is the Collatz sequence of"; x Do While x <> 1 If odd(x) Then x = 3 * x + 1 Else x = x \ 2 End If Print x, If n Mod 6 = 0 Then Print '6 numbers per line n = n + 1 Loop Print Print "The sequence has length"; n End Sub Function odd (n) odd = n Mod 2 <> 0 End Function