RosettaCodeData/Task/Trabb-Pardo-Knuth-algorithm/Ring/trabb-pardo-knuth-algorithm.ring

29 lines
473 B
Text
Raw Permalink Normal View History

2018-06-22 20:57:24 +00:00
# Project : Trabb PardoKnuth algorithm
decimals(3)
x = list(11)
for n=1 to 11
x[n] = n
next
s = [-5, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6]
for i = 1 to 11
see string(i) + " => " + s[i] + nl
2016-12-05 23:44:36 +01:00
next
2018-06-22 20:57:24 +00:00
see copy("-", 20) + nl
i = i - 1
while i > 0
see "f(" + string(s[i]) + ") = "
x = f(s[i])
if x > 400
see "-=< overflow >=-" + nl
else
see x + nl
ok
i = i - 1
end
2016-12-05 23:44:36 +01:00
2018-06-22 20:57:24 +00:00
func f(n)
return sqrt(fabs(n)) + 5 * pow(n, 3)