| Author |
Comment/Response |
Jared E
|
09/21/12 3:43pm
I would like to create a table of the number of steps it takes for an iterative task. The following code creates a table of the fixed point reached in the iterated sum of prime factors process. (It generates OEIS sequence A029908). I would like to know how to create a table that lists the number of steps it took to get to each fixed point. In other words, I need some code that would generate OEIS sequence A002217.
ffi[x_] :=
Flatten[FactorInteger[x]] lf[x_] :=
Length[FactorInteger[x]] ba[x_] :=
Table[Part[ffi[x], 2*w - 1], {w, 1, lf[x]}] ep[x_] :=
Table[Part[ffi[x], 2*w], {w, 1, lf[x]}] slog[x_] :=
slog[x_] :=
Apply[Plus, ba[x]*ep[x]] Table[FixedPoint[slog, w], {w, 1, 128}]
f[n_] := Plus @@
Flatten[Table[#[[1]], {#[[2]]}] & /@ FactorInteger@n]; Array[
FixedPoint[f, #] &, 1000]
URL: , |
|