Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'How to create a table of the number of steps?' topicStudent Support Forum > General > Archives > "How to create a table of the number of steps?"

Next Comment >Help | Reply To Topic
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: ,

Subject (listing for 'How to create a table of the number of steps?')
Author Date Posted
How to create a table of the number of steps? Jared E 09/21/12 3:43pm
Re: How to create a table of the number of steps? Bill Simpson 09/21/12 6:30pm
Re: How to create a table of the number of steps? Peter Pein 09/24/12 01:51am
Next Comment >Help | Reply To Topic