Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
23
Task/Nth-root/GW-BASIC/nth-root.basic
Normal file
23
Task/Nth-root/GW-BASIC/nth-root.basic
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
100 REM Nth root
|
||||
110 X# = 144
|
||||
120 PRINT "Finding the nth root of"; X#; "to 6 decimal places"
|
||||
130 PRINT " x n root x ^ (1 / n)"
|
||||
140 PRINT "--------------------------------------"
|
||||
150 FOR I% = 1 TO 8
|
||||
160 PRINT USING "### "; X#;
|
||||
170 PRINT USING "#### "; I%;
|
||||
180 N% = I%: PREC# = .0000001#: GOSUB 1000
|
||||
190 PRINT USING "###.######"; NTH.ROOT#;
|
||||
200 PRINT USING " ###.######"; X# ^ (1 / I%)
|
||||
210 NEXT I%
|
||||
220 END
|
||||
1000 REM Calculate the N%th root of value X# to stated precision PREC#
|
||||
1010 REM Result: NTH.ROOT#
|
||||
1020 X0# = X#
|
||||
1030 X1# = X# / N% ' initial guess
|
||||
1040 WHILE ABS(X1# - X0#) > PREC#
|
||||
1050 X0# = X1#
|
||||
1060 X1# = ((N% - 1) * X1# + X# / X1# ^ (N% - 1)) / N%
|
||||
1070 WEND
|
||||
1080 NTH.ROOT# = X1#
|
||||
1090 RETURN
|
||||
Loading…
Add table
Add a link
Reference in a new issue