Well in your Arduino example this line in the for loop:
resul[addr] = (addr+2)*(addr-1);
If addr = 255 the result is 65,278 but if addr = 256 the result is 65,790. The largest number that can be stored in an unsigned int on an Arduino is 65,535. If you change your unsigned int to unsigned long it should overcome this problem.