Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Magic-constant/PureBasic/magic-constant.basic
Normal file
25
Task/Magic-constant/PureBasic/magic-constant.basic
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
Procedure.i a(n.i)
|
||||
n + 2
|
||||
ProcedureReturn n*(Pow(n,2) + 1)/2
|
||||
EndProcedure
|
||||
|
||||
Procedure.i inv_a(x.i)
|
||||
k.i = 0
|
||||
While k*(Pow(k,2)+1)/2+2 < x
|
||||
k + 1
|
||||
Wend
|
||||
ProcedureReturn k
|
||||
EndProcedure
|
||||
|
||||
OpenConsole()
|
||||
PrintN("The first 20 magic constants are:")
|
||||
For n.i = 1 To 20
|
||||
Print(Str(a(n)) + " ")
|
||||
Next n
|
||||
PrintN("") : PrintN("")
|
||||
PrintN("The 1,000th magic constant is " + Str(a(1000)))
|
||||
|
||||
For e.i = 1 To 20
|
||||
PrintN("10^" + Str(e) + ": " + #TAB$ + Str(inv_a(Pow(10,e))))
|
||||
Next e
|
||||
CloseConsole()
|
||||
Loading…
Add table
Add a link
Reference in a new issue