Undulating number

An undulating number is a number that has the digit form ABABAB... when in the base 10 number system. It is sometimes restricted to non-trivial undulating numbers which are required to have at least three digits and A ≠ B. The first few such numbers are:


 * 101, 121, 131, 141, 151, 161, 171, 181, 191, 202, 212, 232, 242, 252, 262, 272, 282, 292, 303, 313, 323, 343, 353, 363, 373, 383, 393, 404, 414, 424, 434, 454, 464, 474, 484, 494, ...

For the full sequence of undulating numbers, see.

Some larger undulating numbers are: 1010, 80808, 171717, 989898989.

Properties

 * There are infinitely many undulating numbers.
 * For any n ≥ 3, there are 9 &times; 9 = 81 non-trivial n-digit undulating numbers, since the first digit can have 9 values (it cannot be 0), and the second digit can have 9 values when it must be different from the first.
 * Every undulating number with even number of digits and at least four digits is composite, since: ABABAB...AB = 10101...01 × AB. For example, 171717 = 10101 × 17.
 * Undulating numbers with odd number of digits are palindromic. They can be prime, for example 151.
 * The undulating number ABAB...AB with n repetitions of AB can be expressed as AB × (102n − 1)/99. For example, 171717 = 17 × (106 − 1)/99.
 * The undulating number ABAB...ABA with n repetitions of AB followed by one A can be expressed as (AB × 102n+1 − BA)/99. For example, 989898989 = (98 × 109 − 89)/99
 * Undulating numbers can be generalized to other bases. If a number in base $$b$$ with even number of digits is undulating, in base $$b^2$$ it is a repdigit.

Undulating primes
An undulating prime is an undulating number that is also prime. In every base, all undulating primes having at least three digits have an odd number of digits and are palindromic primes. The undulating primes in base 10 are:
 * 2, 3, 5, 7, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 131, 151, 181, 191, 313, 353, 373, 383, 727, 757, 787, 797, 919, 929, 18181, 32323, 35353, 72727, 74747, 78787, 94949, 95959, ...