```
public class Solution {
public int HammingWeight(uint n) {
if (n==1 || n == 1){
return n;
}
if (n==0){
return 0;
}
var lg = (uint)(Math.Log(n)/Math.Log(2));
return 1 + HammingWeight((uint)(n - Math.Pow(2,lg)));
}
}
```