Jensen's Device: Difference between revisions

Content deleted Content added
Line 89: Line 89:


on jsum(i, lo, hi, term)
on jsum(i, lo, hi, term)
set temp to 0
set {temp, i's contents} to {0, lo}
repeat while i's contents hi
set i to lo
repeat with i from lo to hi
set temp to temp + (term's f(i))
set temp to temp + (term's f(i))
set i's contents to (i's contents) + 1
end repeat
end repeat
return temp
return temp
Line 103: Line 103:
end script
end script


return jsum(i, 1, 100, term_func)</lang>
return jsum(a reference to i, 1, 100, term_func)</lang>
Output: 5.18737751764
Output: 5.18737751764