There is nothing wrong with the println
. Your code does exactly what I'd expect it to do. Consider the last line, which you claim isn't correct:
1023;3850
The decimal 1023
is 1111111111
in binary. Therefore when i=1023
, the inner loop of your program would simply compute the sum of all numbers in list
. These numbers add up to 3850
, which is what gets printed.