by Perry Winkle (2 Submissions)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 7th March 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)
I wrote this code to solve the Goldbach Conjecture. The problem is explained in the code.
API Declarations
'Include two command buttons, a listbox, and a label
Label1 = ""
List1.Clear
On Error GoTo Errorhandler
X = InputBox("Please Enter an Integer.", "Goldbach Conjecture")
If X <> "" Then
List1.AddItem Str(X)
Do While X <> 1
If X Mod 2 = 0 Then
X = X / 2
Else
X = (X * 3) + 1
End If
List1.AddItem Str(X)
Loop
'Number of steps used
Label1 = List1.ListCount - 1
End If
Errorhandler:
Exit Sub
End Sub
Private Sub Command2_Click()
nl = Chr$(13) & Chr$(10)
msg = "Even numbers are divided by 2" & nl
msg = msg & "Odd numbers are multiplied by 3 and are then increased by 1" & nl
msg = msg & "The problem ends by reaching the number 1"
MsgBox msg, , "Goldbach Conjecture Explained"
End Sub
No comments have been posted about I wrote this code to solve the Goldbach Conjecture. The problem is explained in the code.. Why not be the first to post a comment about I wrote this code to solve the Goldbach Conjecture. The problem is explained in the code..