Here you will find daily news and tutorials about R, contributed by over 750 bloggers.
There are many ways to follow us - By e-mail:On Facebook: If you are an R blogger yourself you are invited to add your own R content feed to this site (Non-English R bloggers should add themselves- here)

Does there exist a function f from N to N such that (i) f is (strictly) increasing, (ii) f(n)≥n, and (iii) f²(n)=f(f(n))=3n?

Indeed, the constraints imply (i) f²(0)=0, hence that that f(0)=0, (ii) f(1)=2 as it can be neither 1 (else f²(1) would be equal to 1, not to 3) nor 3 (else f(3)=f²(1)=3 would contradict both f(3)>f(1) and f²(3)=9), and thus (iii) f(2)=f²(1)=3. Those two initial values are sufficient to determine all subsequent values of f(n) as there are exactly three possible values between f²(n)=3n and f²(n+1)=3(n+1)=3n+3. (Kind of shaky argument, I must say, but each time an integer n has no antecedent in the previous f(m)’s, there are exactly two possible and successive values for two indeterminate f(n)’s…)

To plot the above function, I used the R code below:

fillin<-function(N=100){
vals=rep(0,N)
vals[1]=2
for (i in 2:N){
#anc for antecedent, f(anc)=i
u=0;anc=which(vals==i)
#no antecedent
if (length(anc)==0){
u=1; anc=which(vals==i-1)}
if (length(anc)==0){
u=2; anc=which(vals==i-2)}
vals[i]=3*anc*(u==0)+(u>0)*(vals[i-u]+u)}
}

The graph has one interesting feature, which explains why I did not plot the axes, namely that it is somewhat self-reproducing, in that the plot for N=10³ has the same pattern as the plot for N=10⁵, with a few long linear parts around the line y=√3x (since f is essentially an integer-valued version of √3x). Each linear part is about 3 times longer than the earlier one, with slopes of b=1 and b=3 alternating.

While the resolution is obvious for f²(n)=4n, since f(n)=√4n=2n, there is no single resolution when f²(n)=5n. (Maybe there is one if instead the third condition is that f⁴(n)=5n… A new puzzle for the reader.)