Tag Info

New answers tagged

9

In the first example, the list r1 is getting shorter each iteration, resulting in much fewer iterations overall: max = 10^5; r1 = Range[max]; c1 = 0; Timing[ For[i = 2, i <= Length[r1], i++, c1++; r1 = del[r1, i]]; c1] (* ==> {0.012426, 356} *) r2 = Range[max]; c2 = 0; Timing[Do[c2++; r2 = del[r2, i], {i, 2, Length@r2}]; c2] (* ==> ...



Top 50 recent answers are included