Per Vognsen on Nostr: nprofile1q…6gyrf I'm invariant-pilled but I think I slightly prefer to think of ...
nprofile1qy2hwumn8ghj7un9d3shjtnddaehgu3wwp6kyqpqf3nlrmpjja65pzmvlegyl27l0y2m007nncxttdwqndrejajvdzask6gyrf (nprofile…gyrf) I'm invariant-pilled but I think I slightly prefer to think of this algorithm in terms of algebraic laws:
popcount(0) = 0
popcount(x) = popcount(clear_lowest_bit(x)) + 1 if x != 0
This can be turned directly into a function definition. Of course you have also have to prove clear_lowest_bit(x) = x & (x - 1) if x != 0.
popcount(0) = 0
popcount(x) = popcount(clear_lowest_bit(x)) + 1 if x != 0
This can be turned directly into a function definition. Of course you have also have to prove clear_lowest_bit(x) = x & (x - 1) if x != 0.