Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Nth-root/M2000-Interpreter/nth-root.m2000
Normal file
24
Task/Nth-root/M2000-Interpreter/nth-root.m2000
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
Module Checkit {
|
||||
Function Root (a, n%, d as double=1.e-4) {
|
||||
if n%=0 then Error "Division by zero: 1/0"
|
||||
if a<=0 then Error "Negative or zero number"
|
||||
if n%=1 then = a : exit
|
||||
Flush
|
||||
n2=1-1/n%:a/=n%:n%--:Push a
|
||||
{ Push 1: For i=1 to n% {Over 2 :Push Number*Number}
|
||||
Over 2 : Push n2*Number + a/Number
|
||||
Shift 2: Over 2, 2 :if Abs(Number-Number)>d Then loop
|
||||
Drop
|
||||
} Read a : = a
|
||||
}
|
||||
Print "square root single"
|
||||
Print root(1.3346767~, 2, 1.e-9)
|
||||
Print "square double"
|
||||
Print root(1.3346767, 2, 1.e-9)
|
||||
Print "square root decimal"
|
||||
Print root(1.3346767@, 2, 1.e-9)
|
||||
Print "internal square root, double"
|
||||
Print 1.3346767^(1/2)
|
||||
Print sqrt(1.3346767)
|
||||
}
|
||||
Checkit
|
||||
Loading…
Add table
Add a link
Reference in a new issue