Ah, you're right, I didn't think it through. It does feel like there must be a way to play with the bits so that you can retrieve it in a single pass, though - that'd be a much more interesting problem :).
(of course, you can do it with sum + product, but that's going to be fairly expensive for large numbers)
(of course, you can do it with sum + product, but that's going to be fairly expensive for large numbers)