Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Nth-root/Chipmunk-Basic/nth-root.basic
Normal file
20
Task/Nth-root/Chipmunk-Basic/nth-root.basic
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
10 rem Nth root
|
||||
20 print "Finding the nth root of 144 to 6 decimal places"
|
||||
30 print " x n root"
|
||||
40 print "------------------------"
|
||||
50 for i = 1 to 8
|
||||
60 print using "### ";144;
|
||||
70 print using "#### ";i;
|
||||
80 print using "###.######";nthroot(i,144,1.000000E-07)
|
||||
90 next i
|
||||
100 end
|
||||
1000 sub nthroot(n,x,precision)
|
||||
1010 rem Returns the nth root of value x to stated precision
|
||||
1020 x0 = x
|
||||
1030 x1 = x/n ' - initial guess
|
||||
1040 while abs(x1-x0) > precision
|
||||
1050 x0 = x1
|
||||
1060 x1 = ((n-1)*x1+x/x1^(n-1))/n
|
||||
1070 wend
|
||||
1080 nthroot = x1
|
||||
1090 end sub
|
||||
Loading…
Add table
Add a link
Reference in a new issue