- Home
·
- Math/Dates
·
- This code solves the necklace problem. The problem begins with the user entering two digits. The di
This code solves the necklace problem. The problem begins with the user entering two digits. The di
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
Rate This code solves the necklace problem. The problem begins with the user entering two digits. The di
(1(1 Vote))
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
This code solves the necklace problem. The problem begins with the user entering two digits. The di Comments
No comments yet — be the first to post one!
Post a Comment