32 lines
577 B
Plaintext
32 lines
577 B
Plaintext
long def fn MagicConstant( n as long ) = n*(n^2+1)/2
|
|
|
|
UInt64 local fn InvA( x as double )
|
|
UInt64 k = 0
|
|
while ( k*(k^2+1)/2+2 < x )
|
|
k++
|
|
wend
|
|
end fn = k
|
|
|
|
void local fn DoIt
|
|
window 1, @"Magic constant", (0,0,640,400)
|
|
print @"First 20 magic constants:"
|
|
long n = 3
|
|
while n <= 1002
|
|
if ( n <= 22 )
|
|
print fn MagicConstant( n );@" ";
|
|
end if
|
|
if ( n == 1002 ) then print @"\n\n1000th magic constant: ";fn MagicConstant(1002)
|
|
n++
|
|
wend
|
|
|
|
print
|
|
|
|
for long e = 1 to 20
|
|
printf @"10^%ld: %ld",e,fn InvA(10^e)
|
|
next
|
|
end fn
|
|
|
|
fn DoIt
|
|
|
|
HandleEvents
|