|
|
A293689
|
|
Position of the prime ant after n steps. If the value of the ant's position is prime, it steps to the right; if the value is composite, it divides by the least divisor, steps to the left, and adds the divisor.
|
|
1
|
|
|
0, 1, 2, 1, 2, 3, 4, 3, 4, 5, 6, 5, 4, 3, 2, 3, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7, 8, 9, 10, 9, 10, 9, 8, 7, 8, 7, 6, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 10, 11, 12, 13, 12, 11, 12, 13, 14, 13, 14, 13, 12, 11, 10, 9, 8, 9, 10, 11, 12, 11, 12, 13
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,3
|
|
COMMENTS
|
a(n) gives the position after the n-th step on the infinite sequence (2, 3, 4, ...). If the value at the ant's position is prime, the ant steps to the right. If the value is composite, the ant divides the number by its least prime divisor, steps to the left, and adds the divisor to the new position.
|
|
LINKS
|
|
|
EXAMPLE
|
a(0) = 0:
2 3 4 5 6 7 ...
^ (prime; step to the right)
a(1) = 1:
2 3 4 5 6 7 ...
^ (prime; step to the right)
a(2) = 2:
2 3 4 5 6 7 ...
^ (composite; divide by 2, step to the left, add 2)
a(3) = 1:
2 5 2 5 6 7 ...
^ (prime; step to the right)
a(4) = 2:
2 5 2 5 6 7 ...
^
|
|
MATHEMATICA
|
NestWhileList[If[PrimeQ[#2[[#1]] ], {#1 + 1, #2}, {#1 - 1, ReplacePart[#2, {#1 - 1 -> #2[[#1 - 1]] + #3, #1 -> #2[[#1]]/#3}]} & @@ {#1, #2, FactorInteger[#2[[#1]] ][[1, 1]]}] & @@ # &, {2, Range[10^2]}, First@ # < Length@ Last@ # &, 1, 78][[All, 1]] - 2 (* Michael De Vlieger, Oct 15 2017 *)
|
|
CROSSREFS
|
|
|
KEYWORD
|
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|