I wonder if building this table can be sped up by noticing a recurring pattern?
x 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ... 254 255
f(x) 0 0 1 2 3 3 4 5 6 6 7 8 9 9 10 11 12 12 ... 190 191
So something like sta table,y
iny
sta table,y
adc $0
iny
sta table,y
adc $0
iny
sta table,y
adc $0
iny
used as the loop body that should be repeated 64 times, should work. Will it take less than 6000 cycles total?