N1
leftover square root
9 3
4 2
49 7
36 6
289 17
25 5
256 16
1 1
16 4
169 13
1369 37
13689 117
134689 367 minimum number of digits erased: 3
13456 116
N2
leftover square root
1 1
4 2
64 8
81 9
841 29 minimum number of digits erased: 6
9 3
961 31 minimum number of digits erased: 6
DefDbl A-Z
Dim crlf$, nx$, leftovers$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr(13) & Chr(10)
nx$ = "123456789"
leftovers = ""
buildon 1
nx$ = "987654321"
leftovers = ""
buildon 1
Text1.Text = Text1.Text & crlf & ct & " done"
End Sub
Sub buildon(wh)
For i = 0 To 1
DoEvents
sve$ = leftovers
If i Then leftovers = leftovers + Mid(nx, wh, 1)
If wh = 9 Then
sq = Val(leftovers)
sr = Int(Sqr(sq) + 0.5)
If sr * sr = sq Then
Text1.Text = Text1.Text & mform(sq, "#####0") & " " & mform(sr, "#####0") & crlf
End If
Else
buildon (wh + 1)
End If
leftovers = sve
Next
End Sub
Function mform$(x, t$)
a$ = Format$(x, t$)
If Len(a$) < Len(t$) Then a$ = Space$(Len(t$) - Len(a$)) & a$
mform$ = a$
End Function
|
Posted by Charlie
on 2018-04-05 12:27:33 |