Fibonacci is defined recursively for this question as: F~0 = 1 F~1 = 1 F~n = F~n-1 + F~n-2 for n >= 2 So a custom binary string always begins with 1 and never has two consecutive ones. If s = s~Ls~L-1...s~1 is such a string of length L where s~i is in {0,1}, the number represented by s is: n(s) = Sigma (i = 1 to L) s~i x F~i Example: n(1000101) = F~7 + F~3 + F~1 = 21 + 3 + 1 = 25
(a) Prove for every L >= 1, if s is a custom binary number of length L, n(s) >= F~L
(b) Prove for every L >= 1, if s is a custom binary number of length L, n(s) < F~L + 1
I've tried to prove with induction with no luck most likely because I'm doing it wrong. I'm not sure how else to prove it for the general case of L > 1.
The '~' is to represent there is a subscript for the variable
Let's start with A.
I would prove it this way:
Let
s
be a custom binary string withL=k
such thatk>=1
. By definition of custom binary strings, we must haves~k = 1
Thereforen(s) = F~k + n(s~(k-1)...s(1)) = F~L + n(s~(k-1) ... s(1))
, or the number represented bys
is equal toF~L
plus the number represented by the remainingk-1
digits ofs
. Since we cannot have a string with negative length, we must have thatn(s) >= F~L
However, if you need to prove it inductively, you could do it this way:
Base case: Let
L=1
ands
be a custom binary string of length 1. We must haves=1
, by definition. Thereforen(s) = n(1) = 1xF~1 = F~L
, as required.Inductive Hypothesis: Assume that
n(s) >= F~L
forL=1,2,...k-1
.Inductive case: Let
L=k
, and lets
be a custom binary string of lengthk
.If
s
contains only one digit equal to1
, this is equivalent to the base case and we are done.If
s
contains more than one digit equal to1
, leti
be the index of the second occurrence, and lett
be the custom binary string represented by the digitss~i ... s~1
. Then we have thatn(s) = 1xF~k + n(t) = F~L + n(t)
. Sincet
has lengthk-i
, by the inductive hypothesis we haven(s) >= F~L + F~(k-i)>= F~L
, as required.
Okay, B is going to be harder. I'm going to prove it inductively, because I think it's easier.
Base case: Let
L=1
ans
be a custom binary string of length 1. We must haves=1
, by definition. Thereforen(s) = n(1) = 1xF~1 = 1 < 2 = F~2
.Inductive Hypothesis: Assume that n(s) < F~(L+1)
for
L=1,2,...,k-1`.Inductive Case: Let
L=k
ands
be a custom binary string of lengthk
.If
s
has only one digit equal to1
, this is equivalent to the base case and we're done. Ifs
has more than one digit equal to1
, then leti
be the index of the second occurrence, andt
be the custom binary string represented by the digitss~i ... 1
.It is obvious that
n(s) = F~L + n(t)
. By the inductive hypothesis we know thatn(t) < F~(i+1)
. Since custom binary strings cannot have consecutive digits be1
, we also have thati <= L-2
, ori+1 <= L-1
, which means thatF~(i+1) <= F~(L-1)
since the Fibonacci sequence is strictly increasing.Putting it all together:
n(s) = F~L + n(t) < F~L + F~(i+1) < F~L + F~(L-1) = F~(L+1).
Therefore
n(s) < F~(L+1)
, as required.