1 / 2 + 1 / 4 + 1 / 8 +. 1 / 256 how to calculate with simple algorithm

1 / 2 + 1 / 4 + 1 / 8 +. 1 / 256 how to calculate with simple algorithm

1/2+1/4+1/8+1/16+.+1/256
=1 / 2 + 1 / 4 + 1 / 8 + 1 / 16 +. + 1 / 256 + 1 / 256-1 / 256 (add the last number and subtract the last number)
=1/2+1/4+1/8+1/16+.+1/128+1/128-1/256
=1/2+1/4+1/8+1/16+.+1/64+1/64-1/256
.
=1/2+1/2-1/256
=1-1/256
=255/256