Great thanks very much for that!
I'll use your code for now and try to modify it so it doesn't need sort or the checking loop.
As for your questions, 3/15 (=1/5 which is the result given), is only supposed to appear for n=4. In general, the 'initial' (by initial, I mean point in the first interval) will be of the form k/(2^n - 1) where I'm almost certain k will be odd.
"But I'm curious, why were the two inequalities in the "check" on S[k] both strict"
By strict so you mean <= instead of just <?
I suppose it won't actually matter since no point tested will be at one of the interval endpoints but yes < and > could be used instead.
I have two additional questions though.
What do the d1,d2 and d3 stand for here...
I know g() is garbage collection but I'm unsure as to what the other terms do.
Finally, is this a situation where compile might be useful? I've never really used it before except when another
member here gave me a code with compile in it but it seems to speed things up massively.