Given an integer
x1 and some black box function
f: ℤ → ℤ find a fixed point of
f in the sequence defined by
xk+1 := f(xk).
xis said to be a fixed point of
x = f(x).
For instance if
f(x) := round(x/pi)and we have a starting point
x1 = 10then we get
x2 = f(x1) = f(10) = 3, then
x3 = f(x2) = f(3) = 1, then
x4 = f(x3) = f(1) = 0, and finally
x5 = f(x4) = f(0) = 0which means the submission should return
- You can assume that the generated sequence actually contains a fixed point.
- You can use the native type for integers in place of
- You can use any language for which there are defaults for black box functions input in the standard IO meta post. If there are no such default for your language feel free to add one in the sense of the definition of black box functions, and make sure to link your proposals in that definition. Also don't forget to vote on them.
f(x) = floor(sqrt(abs(x))) 0 -> 0, all other numbers -> 1 f(x) = c(c(c(x))) where c(x) = x/2 if x is even; 3*x+1 otherwise all positive numbers should result in 1,2 or 4 (Collatz conjecture) f(x) = -42 all numbers -> -42 f(x) = 2 - x 1 -> 1