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)
This code solves the necklace problem. The problem begins with the user entering two digits. The digits are then added together, and if they
API Declarations
'a listbox, and a label
Dim X, Y, W, Z, U As Integer
If Trim(Text1) <> "" And Trim(Text2) <> "" Then
List1.Clear
X = Val(Text1)
Y = Val(Text2)
W = Right(X + Y, 1)
Z = Right(W + Y, 1)
List1.AddItem Str(X)
List1.AddItem Str(Y)
List1.AddItem Str(W)
List1.AddItem Str(Z)
U = W
Do While Str(X) + Str(Y) <> Str(U) + Str(Z)
W = Right(U + Z, 1)
U = Z
Z = W
List1.AddItem Str(W)
Loop
End If
'Number of steps used to complete the problem
Label1 = List1.ListCount - 2
End Sub
No comments have been posted about This code solves the necklace problem. The problem begins with the user entering two digits. The di. Why not be the first to post a comment about This code solves the necklace problem. The problem begins with the user entering two digits. The di.