TCS
Company
Category
A function f satisfies f(0) = 0, f(2n) = f(n), and f(2n+1) = f(n) + 1 for all positive integers n. What is the value of f(2018) ?
Read Solution (Total 9)
-
- f(2018)=f(1009)
f(1009)=f(2*504+1)=f(504)+1
=f(252)+1
=f(126)+1
=f(63)+1
=f(2*31+1)+1
=f(31)+2
=f(2*15+1)+2
=f(15)+3
=f(2*7+1)+3
=f(7)+4
=f(2*3+1)+4
=f(3)+5
=f(2*1+1)+5
=f(1)+6
=f(2*0+1)+6
=f(0)+7
=0+7
=7 - 6 years agoHelpfull: Yes(24) No(0)
- i did not understand
- 6 years agoHelpfull: Yes(4) No(1)
- f(2018)=f(1009)
f(1009)=f(2*504+1)=f(504)+1
=f(252)+1
=f(126)+1
=f(63)+1
=f(2*31+1)+1
=f(31)+2
=f(2*15+1)+2
=f(15)+3
=f(2*7+1)+3
=f(7)+4
=f(2*3+1)+4
=f(3)+5
=f(2*1+1)+5
=f(1)+6
=f(2*0+1)+6
=f(0)+7
=0+7
=7 - 6 years agoHelpfull: Yes(2) No(0)
- f(2018)=f(1009)
f(1009)=f(2*504+1)=f(504)+1
=f(252)+1
=f(126)+1
=f(63)+1
=f(2*31+1)+1
=f(31)+2
=f(2*15+1)+2
=f(15)+3
=f(2*7+1)+3
=f(7)+4
=f(2*3+1)+4
=f(3)+5
=f(2*1+1)+5
=f(1)+6
=f(2*0+1)+6
=f(0)+7
=0+7
=7
Ans - 6 years agoHelpfull: Yes(1) No(0)
- 7
F(2018)=f(1009)=f(504)+1=f(252)+1=f(126)+1=f(63)+1=f(31)+2=f(15)+3=f(7)+4=f(3)+5=f(1)+6=f(0)+7=0+7=7 - 5 years agoHelpfull: Yes(1) No(0)
- f(2*0+1) = f(0) + 1 =1
f(1) = 1
f(2*1) = f(1) => f(2) = f(1) = 1
f(2018) = 1 - 6 years agoHelpfull: Yes(0) No(6)
- f(2018)=f(2x1009)=f(504+1)=f(2x252+1)=f(252)+1
f(252)=f(2X126)=f(126)=f(2X63)=f(63)=f(2X31+1)=f(31)+1
f(31)=f(2X15+1)=f(15)+1
f(15)=f(2X7+1)=f(7)+1
f(7)=f(2X3+1)=f(3)+1
f(3)=f(2X1+1)=f(2)+1
f(2)=f(2X1)=f(1)
f(1)=f(2X0+1)=f(0)+1=1
So we have, f(1)=1
f(2)=1
f(3)=1+1
f(7)=2+1
f(15)=3+1
f(31)=4+1
f(252)=5+1
f(2018)=6+1=7 Ans. - 6 years agoHelpfull: Yes(0) No(0)
- f(2n)=f(n)
2n=n
f(2*1009)=f(1009); - 6 years agoHelpfull: Yes(0) No(0)
- Odd and even function
f(1)=f(0+1)=f(0)+1=0+1=1
f(2018)=f(1009)
=f(504)+1
=f(252)+1
=f(126)+1
=f(63)+1
=f(31)+1+1
=f(15)+1+2
=f(7)+1+3
=f(3)+1+4
=f(1)+1+5
=1+6
=7 - 5 years agoHelpfull: Yes(0) No(1)
TCS Other Question