Problem

Source: Mexico National Olympaid 2019 P5

Tags: number theory, algebra



Let a>b be relatively prime positive integers. A grashopper stands at point 0 in a number line. Each minute, the grashopper jumps according to the following rules: If the current minute is a multiple of a and not a multiple of b, it jumps a units forward. If the current minute is a multiple of b and not a multiple of a, it jumps b units backward. If the current minute is both a multiple of b and a multiple of a, it jumps ab units forward. If the current minute is neither a multiple of a nor a multiple of b, it doesn't move. Find all positions on the number line that the grasshopper will eventually reach.