Data update

This commit is contained in:
Ingy döt Net 2025-06-11 20:16:52 -04:00
parent 72eb4943cb
commit 4d5544505c
2347 changed files with 62432 additions and 16731 deletions

View file

@ -0,0 +1,23 @@
set outPutString to ""
set outPutString to outPutString & nthRoot2(34, 5) & linefeed
set outPutString to outPutString & nthRoot2(42, 10) & linefeed
set outPutString to outPutString & nthRoot2(5, 2) & linefeed
on nthRoot(x, n)
local n1, y, res, abs
set n1 to n - 1
set res to x / n
set abs to x
repeat until abs < 1.0E-14
set y to res
set res to ((n1 * y) + (x / (y ^ n1))) / n
if res > y then
set abs to res - y
else
set abs to y - res
end if
end repeat
set y to res div 1
if res = y then return y
return res
end nthRoot

View file

@ -1,8 +1,6 @@
func power x n .
r = 1
for i = 1 to n
r *= x
.
for i = 1 to n : r *= x
return r
.
func nth_root x n .
@ -15,6 +13,8 @@ func nth_root x n .
.
return r
.
numfmt 4 0
numfmt 0 4
x = power 3.1416 10
print nth_root x 10
print nth_root 2 2
print nth_root 81 4

View file

@ -1,17 +1,22 @@
/*REXX program calculates the Nth root of X, with DIGS (decimal digits) accuracy. */
-- 8 May 2025
include Settings
say version; say 'Nth root'; say
parse arg x root digs . /*obtain optional arguments from the CL*/
if x=='' | x=="," then x= 2 /*Not specified? Then use the default.*/
if root=='' | root=="," then root= 2 /* " " " " " " */
if digs=='' | digs=="," then digs=65 /* " " " " " " */
numeric digits digs /*set the decimal digits to DIGS. */
say ' x = ' x /*echo the value of X. */
say ' root = ' root /* " " " " ROOT. */
say ' digits = ' digs /* " " " " DIGS. */
say ' answer = ' Nroot(x, root) /*show the value of ANSWER. */
exit /*stick a fork in it, we're all done. */
say 'NTH ROOT'
say version
say
parse arg x','root','digs
if x = '' then
x = 2
if root = '' then
root = 5
if digs = '' then
digs = 65
numeric digits digs
say ' x = ' x
say ' root = ' root
say 'digits = ' digs
say 'answer = ' Nroot(x,root)
exit
include Numbers
include Functions