K Sengupta said:
Consider all functions g from the positive integers to the positive integers such that:
(a) For each positive integer p there exists an unique positive integer q such that g(q) = p;
(b) For each positive integer q, we have g(q+1) as either 4g(q) -1; or;
g(q) -1.
Determine the set of positive integers s such that:
g(1999) = s; for some function g possessing both the properties (a) and (b).
So (a) tells me the map is one to one and onto on the natural numbers, it is an isomorphism. (b) actually defines the function itself as
g(q) = p (p here is not to be construed as prime)
g(q+1) = 4g(q)-1 = 4p-1 OR g(q+1) = g(q) - 1 = p - 1
Well by the rules of the game we must have
g(1) = 3 since 1-1 = 0 is not a natural number (positive integer)
g(2) = 2 since no other number can be mapped to two save three under the rules
g(3) = 1 since no other number can be mapped to one save two under the rules
g(4) = 15 since 1-1 = 0 is not a natural number.
g(5) = 14
g(6) = 13
g(7) = 12
g(8) = 11
g(9) = 10
g(10) = 9
g(11) = 8
g(12) = 7
g(13) = 6
g(14) = 5
g(15) = 4?
g(16) = 15? already mapped so we have to step back and do
g(15) = 19
g(16) = 18
g(17) = 17
g(18) = 16
g(19) = 63
.
.
.
.
etc. So such a function does exist. But the questions that remain are several, is g a unique map or are there many ways to do it? If there is only one function g that satisfies the properties then there is only one s satisfying the question. What we should do is try understand the class of acceptable functions {g}. Notice in the above construction everything up to g(4) is unique but g(5) can be either 14 or 63? If one of these two choices proves impossible we might have a clue.
Think of this function as being peicewise and in some sense it is like an automoton. If we choose g(q+1) = g(q)-1 we can move backwards in stepwise fashion. If we choose g(q+1) = 4g(q)-1 we are jumping ahead roughly by a factor of four. It stands to reason that any function g that satisfies the requirements must have the property that for any jump g(q+1)=4g(q)-1, there must exist t such that g(q+1+t) = 4g(q)-1-t = g(s) for some s less than q+1. We would then only be able to backtrack to t-1 since the next jump forward would have to come at g(s+2)=4(4g(q)-t)-1
The trick is to know when the jump is too large to be covered by the available leftover numbers.
So consider this
g(1) = 3
g(2) = 7
g(3) =11
g(4) =15
Notice that 3 insulates 1 and 2 from the higer order four mod threes terms, I have to fill in the gaps by sequentially moving doen from one of the 4p-1. Therefore if I do not account for every integer less than three in the steps before I allow a 4p-1 the condition of 1 to 1 and onto is broken.
So we have to have
g(1) = 3
g(2) = 2
g(3) = 1
g(4) = 15
Now if I allow g(q+1) = 4g(q)-1 before I have accounted for the integers 4,5,6,...14 g is not a valid map under the conditions. So it must be that g(15) = 4 but that implies g(16) = 15 which has already been mapped violating the conditions. So if we go to g(14) = 5 and then g(15) = 19, we have now excluded permanently the number 4. No such function g can exist under these circumstances. Furthermore we would also have to use g(q+1) = g(q)-1 to backtrack and cover everything down to sixteen. Let's pick that up.
g(1) = 3
g(2) = 2
g(3) = 1
g(4) = 15
g(5) = 14
g(6) = 13
g(7) = 12
g(8) = 11
g(9) = 10
g(10) = 9
g(11) = 8
g(12) = 7
g(13) = 6
g(14) = 5 (note 4 is not accounted for)
g(15) = 19
g(16) = 18
g(17) = 17
g(18) = 16
g(19) = 63 (use g(q+1) = g(q)-1 24 times)
.
.
.
g(43) = 20
g(44) = 79 (use g(q+1) = g(q) - 1 16 times)
g(60) = 64
If we adjust the caveats so that we say there is a one to one and onto mapping of N to N-{4} having the properties we are working again. Then there is a pattern starting to develop that is the numbers q that correspond to g(q+1)=4g(q)-1 can be listed once we have passed 4.
so we have
g(15) = 4(5)-1 = 19
g(19) = 4(16)-1 = 63
g(63) = 4(20)-1 = 79
g(79) = 4(64)-1 = 255
g(255) = 4(80)-1 = 319
g(319) = 4(256)-1 = 1015
g(1015) = 4(320) - 1 = 1279
g(1279) = 4(1016) - 1 = 4063
Now we can stop and start counting backwards, so that we have
g(1279+t) = 4063 - t = s
So when 1279+t = 1999 we find that t = 1999-1279=720 and 4063 - 720 = 3343 = s. Thus with the above caveats noted the only possible value for s is 3343.
I like this problem because it sort of turns counting on it's head. We like to count sequentially but here we have to count differently depending on which side of the map we are looking at. Very nice problem!
Also if we allow ourselves the inclusion of zero among the positive integers then
g(0) = 4 (and thus four is acounted for)
g(1) = 3
g(2) = 2
.
.
.
The answer is not changed but the apparent exclusion of four is explained.