35 lines
531 B
Text
35 lines
531 B
Text
Function a(n As Integer) As Long
|
|
|
|
n += 2
|
|
Return n * (n ^ 2 + 1) / 2
|
|
|
|
End Function
|
|
|
|
Function inv_a(x As Float) As Long
|
|
|
|
Dim k As Long = 0
|
|
|
|
While k * (k ^ 2 + 1) / 2 + 2 < x
|
|
k += 1
|
|
Wend
|
|
Return k
|
|
|
|
End Function
|
|
|
|
Public Sub Main()
|
|
|
|
Dim n As Long
|
|
|
|
Print "The first 20 magic constants are: "
|
|
|
|
For n = 1 To 20
|
|
Print a(n); " ";
|
|
Next
|
|
Print
|
|
Print "The 1,000th magic constant is "; a(1000)
|
|
|
|
For e As Integer = 1 To 20
|
|
Print "10^"; Format(e, "##"); ": "; Format(inv_a(10 ^ e), "#########")
|
|
Next
|
|
|
|
End Sub
|