The TransCompilator

Solved LeetCode program · 539 of 1,000

#0762 · Prime Number of Set Bits in Binary Representation

Easy Math chunk-11.md

Original English source

Keep a shared current of 0. Keep a shared bits of 0.
To tally.
Repeat while current is more than 0.
The low is bitwise and of current and 1. Add low to bits. Set current to shift current right by 1.

The left is 6. The right is 10. The primes is a list of 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, and 0. The total is 0.
For every value from left to right.
Set current to value. Set bits to 0. Tally. The count is bits. If item count of primes is 1, add 1 to total.

Show total.

Open in Playground Browse all 1,000 problems

Expected stdout

4