I wrote this program on Mathematica (which I am very new to):
h[n_] := n + n/FactorInteger[n][[-1, 1]] + 1
L = NestList[h,1,10]
Do[Do[If[MemberQ[L, NestList[h, y, 10][[x]], Print[y, " ", x]],{x, 1, 10}],{y, 1, 10}]
(This code may not be particularly efficient, but it's the best I know how to do.) Which basically calculates how many iterations of h
must be applied to y
to reach an element of L
.
When I run the program, I get:
$$1~1$$ $$1~2$$ $$1~3$$ $$1~4$$ $$1~5$$ $$1~6$$ $$1~7$$ $$1~8$$ $$1~9$$ $$1~10$$ $$2~3$$ $$2~4$$ $$2~5$$ $$...$$ $$10~2$$ $$10~3$$ $$10~4$$ $$10~5$$ $$10~6$$ $$10~7$$ $$...$$
(There should be spaces between the numbers)
You can see that the program prints ten values for every y
. It probably requires rewriting of the entire program, but I would like to tell it to only print the first value of y
, so the above list would become:
$$1~1$$ $$2~3$$ $$...$$ $$10~2$$ $$...$$
The values are probably all under 5, but it is possible that there are some greater than 10. I would also like to remove that limit.
I have no idea how to do this, because I do not know Mathematica well enough yet. I would appreciate help with this very much. Thanks.
P.s.: To help clarify, these are the first few values of the output as I would like them to appear, which I have calculated by hand:
$$1~1$$ $$2~3$$ $$3~1$$ $$4~2$$ $$5~1$$ $$6~2$$ $$7~1$$ $$8~2$$ $$9~1$$ $$10~2$$ $$11~2$$ $$12~3$$ $$...$$
And no, I do not want to save this as a list, unless it can be kept in the above format.
Print[***]
. Something like If[y==1,Print[***]] $\endgroup$