login
This site is supported by donations to The OEIS Foundation.

 

Logo

Annual appeal: Please make a donation to keep the OEIS running! Over 6000 articles have referenced us, often saying "we discovered this result with the help of the OEIS".
Other ways to donate

Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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

Peter Kagey, Table of n, a(n) for n = 0..10000

Stack Exchange user Super Chafouin, The Prime Ant.

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

Sequence in context: A259576 A030330 A286579 * A059261 A285869 A162330

Adjacent sequences:  A293685 A293686 A293688 * A293690 A293691 A293692

KEYWORD

nonn,walk,look

AUTHOR

Peter Kagey, Oct 14 2017

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent | More pages
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy .

Last modified November 20 13:59 EST 2017. Contains 294972 sequences.