if n equals 1, return V
set R = right most n/2 bits of V
set L = left most  n/2 bits of V
return countn(L,n/2) + countn(R,n/2)

Example 2: Pseudocode for countn(V,n), which uses recursion to count bits.

Back to Article