Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
24
Task/Magic-constant/FreeBASIC/magic-constant.basic
Normal file
24
Task/Magic-constant/FreeBASIC/magic-constant.basic
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue