25 lines
389 B
Plaintext
25 lines
389 B
Plaintext
function a(n)
|
|
n = n + 2
|
|
return n*(n^2 + 1)/2
|
|
end function
|
|
|
|
function inv_a(x)
|
|
k = 0
|
|
while k*(k^2+1)/2+2 < x
|
|
k += 1
|
|
end while
|
|
return k
|
|
end function
|
|
|
|
print "The first 20 magic constants are:"
|
|
for n = 1 to 20
|
|
print int(a(n));" ";
|
|
next n
|
|
print : print
|
|
print "The 1,000th magic constant is "; int(a(1000)); chr(10)
|
|
|
|
for e = 1 to 20
|
|
print "10^"; e; ": "; chr(9); inv_a(10^e)
|
|
next e
|
|
end
|