Skip to content

Lab04 Post-Lab: Ambiguous Recursive Function Description #39

@mgsanusi

Description

@mgsanusi

"Write a recursive function that returns the number of 1's in the binary representation of n. Use the following fact: if n is even, the number of bits in the representation of n is the same as that in n/2; if n is odd, the number of bits is the same as that in floor(n/2) plus 1."

Clarify that this means num_ones = bitCounter(n/2) + 1, NOT num_ones = bitCounter(n/2 + 1)

As soon as I get the chance, I think I'm going to fix this by saying "if n is odd, the number of ones is the same as 1 plus the number of ones in floor(n/2)"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions