function a(byval n as uinteger) as ulongint n+=2 return n*(n^2 + 1)/2 end function function inv_a(x as double) as ulongint dim as ulongint k = 0 while k*(k^2+1)/2+2 < x k+=1 wend return k end function dim as ulongint n print "The first 20 magic constants are ": for n = 1 to 20 print a(n);" "; next n print print "The 1,000th magic constant is ";a(1000) for e as uinteger = 1 to 20 print using "10^##: #########";e;inv_a(10^cast(double,e)) next e