MathDB
2002 BAMO p5 prime-testing trail of Professor Moriarty, station 1429

Source:

August 26, 2019
combinatoricsnumber theoryprime

Problem Statement

Professor Moriarty has designed a “prime-testing trail.” The trail has 20022002 stations, labeled 1,...,20021,... , 2002. Each station is colored either red or green, and contains a table which indicates, for each of the digits 0,...,90, ..., 9, another station number. A student is given a positive integer nn, and then walks along the trail, starting at station 11. The student reads the first (leftmost) digit of n,n, and looks this digit up in station 11’s table to get a new station location. The student then walks to this new station, reads the second digit of nn and looks it up in this station’s table to get yet another station location, and so on, until the last (rightmost) digit of nn has been read and looked up, sending the student to his or her final station. Here is an example that shows possible values for some of the tables. Suppose that n=19n = 19: https://cdn.artofproblemsolving.com/attachments/f/3/db47f6761ca1f350e39d53407a1250c92c4b05.png Using these tables, station 11, digit 11 leads to station 2929m station 2929, digit 99 leads to station 14291429, and station 14291429 is green. Professor Moriarty claims that for any positive integer nn, the final station (in the example, 14291429) will be green if and only if nn is prime. Is this possible?