Let be a function from the set of all non-negative integers into itself such that:
, and
How many numbers less than are there in the image of ?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
The first step is to show that f ( 2 n + 1 ) = 3 f ( n ) + 1 and f ( 2 n ) = 3 f ( n ) . Certainly any function of this form obeys the conditions.
We get f ( 1 ) 2 = f ( 0 ) 2 + 6 f ( 0 ) + 1 = ( f ( 0 ) + 3 ) 2 − 8 , and the only positive integer solution to x 2 − y 2 = 8 is x = 3 , y = 1 (factor), so f ( 0 ) = 0 and f ( 1 ) = 1 .
Now note that ( f ( 2 n + 1 ) − f ( 2 n ) ) ( f ( 2 n + 1 ) + f ( 2 n ) ) = 6 f ( n ) + 1 and the two factors differ by at least 2 f ( 2 n ) ≥ 2 f ( n ) . So the second factor is at least 2 f ( n ) + 1 , and so the first factor is at most 2 f ( n ) + 1 6 f ( n ) + 1 < 3 .
But the first factor can't be 2 , so it must be 1 , and the second factor is 6 f ( n ) + 1 . So we get f ( 2 n + 1 ) = 3 f ( n ) + 1 and f ( 2 n ) = 3 f ( n ) . Note that together with the values of f ( 0 ) and f ( 1 ) , this uniquely determines f .
One way to describe f ( n ) is that it equals the binary expansion of n translated into ternary. So e.g. f ( 5 ) = 1 0 because 5 is 1 0 1 in binary, and 1 0 1 in ternary is 1 0 . It's pretty clear that this function satisfies the conditions in the first step, so it equals f .
So the answer is the number of numbers less than 2015 whose ternary expansion is all 1 s and 0 s. This is just every number with such a ternary expansion that has up to 7 digits. So there are 2 7 = 1 2 8 such numbers.