RosettaCodeData/Task/Nth-root/S-BASIC/nth-root-1.basic

18 lines
382 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
rem - return nth root of x
function nthroot(x, n = real) = real
end = exp((1.0 / n) * log(x))
rem - exercise the routine by finding successive roots of 144
var i = integer
2025-02-27 18:35:13 -05:00
var x = real
2023-07-01 11:58:00 -04:00
2025-02-27 18:35:13 -05:00
x = 144
print "Finding the nth root of"; x
2023-07-01 11:58:00 -04:00
print " x n root"
print "-----------------------"
for i = 1 to 8
2025-02-27 18:35:13 -05:00
print using "### #### ###.####"; x; i; nthroot(x, i)
2023-07-01 11:58:00 -04:00
next i
end