Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can anyone help me whrite a recursive function that returnsthe number of 1\'s in

ID: 3613395 • Letter: C

Question

Can anyone help me whrite a recursive function that returnsthe number of 1's in the binary representation on N. use the factthat this is equal to the number of 1's in the presentation ofN/2, plus 1 if N is odd. i really need help with thisproblem: i was thinking that in away i have to use % 2, because theNumber(N) will be in decimal and in order to convert itto binary i must divided by two.
can you help me please!!!!!! Can anyone help me whrite a recursive function that returnsthe number of 1's in the binary representation on N. use the factthat this is equal to the number of 1's in the presentation ofN/2, plus 1 if N is odd. i really need help with thisproblem: i was thinking that in away i have to use % 2, because theNumber(N) will be in decimal and in order to convert itto binary i must divided by two.
can you help me please!!!!!!

Explanation / Answer

please rate - thanks you didn't specify the language. Here is C, if you need Java or C++ and cannot convert messageme #include #include int count(int x) { int result; if (x==0) return 0; else result = count(x/2); printf("%d",x%2); if (x%2==1)    result++; return result; } int main() { int n; int ones; printf(" Enter any number for conversion: "); scanf("%d",&n); printf(" Number of 1 bits = %d ",ones); getch(); return 0; }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote