News for hackers. Stuff that matters.
Re:[Stack Overflow]Design a function f, such that f(f(n)) ==... by richardkiss on Friday June 28, 2013 @01:20AM (#5956412)
f(f(n)) = n^2 is actually easy when you consider it restricted to 32-bit signed integers. Since it's impossible to make it work for any abs(n)>65536 (it's too big), you can reserve all those values as intermediate stopover points for the ones it WILL work for.

f(n)

     = abs(n) + 65536               if n < 65536

     = unsigned32(n & 0xffff) ** 2  if n >= 65536
Cheeky, eh?
Re:[Stack Overflow]Design a function f, such that f(f(n)) ==... by pfortuny on Friday June 28, 2013 @03:49AM (#5956795)
Ah, yes. But I was thinking of all the integers.

I know, I should have read the OP but I was too lazy.

Really cheeky, though :)