I am playing a walking game with myself. On move 1, I do nothing, but on move n where 2 \le n \le 25, I take one step forward if n is prime and two steps backwards if the number is composite. After all 25 moves, I stop and walk back to cont. below?

my original starting point. How many steps long is my walk back?

~ Question from AoPS ~

Breakdown:
Subject: Number Theory
Focus: Review Problem

1 Answer
Jul 31, 2018

21 steps

Explanation:

From integers 2 to 25, there are color(red)(9) color(red)(pri me) numbers (2, 3, 5, 7, 11, 13, 17, 19, and 23). That means the remaining color(blue)(15 numbers are color(blue)(composite). You take color(green)(1) step color(green)(f o r w ard) for every prime, and color(purple)(2) steps color(purple)(backwards) for every composite. We can write your position from your original point as:

(color(green)1)(color(red)(9))+(color(purple)(-2))(color(blue)(15))=9-30=-21

This is our displacement; we want d i s t a n c e, so we take the absolute value of -21.

|-21|=21 steps