Need Helping coming up with Need Ideas Thank you in Advance
Need Helping coming up with (Need Ideas) Thank you in Advance!
1. Come up with a clear and interesting conjecture concerning primes or the \"Hailstone\" Sequence.
So that i can later try and code:
2. Write a program that will allow the user (you!) to gather data regarding the conjecture posed in (1) Using Visual Basics.
Solution
Hailstone sequence
If n is even, divide it by 2 to give n\' = n/2
If n is odd, multiply it by 3 and add 1 to give n\' = 3n + 1
Program in visual basic
Dim a, count As Integer
a = TextBox1.Text
count = 0
ListBox1.Items.Clear()
ListBox1.Items.Add(a)
Do While a <> 1
If a Mod 2 = 0 Then
a = a / 2
Else
a = 3 * a + 1
End If
count = count + 1
ListBox1.Items.Add(a)
Loop
TextBox2.Text = count
End Sub
