https://leetcode.com/problems/counting-bits


//rust programming language

impl Solution {
    pub fn count_bits(num: i32) -> Vec<i32> {
        let mut v: Vec<i32> = vec![0 as i32; (num+1) as usize];
        for i in 0..num+1 {
            let mut j: i32 = i;
            while j > 0 {
                v[i as usize] += j % 2;
                j /= 2;
            }
        }
        return v;
    }
}