A378119 a(n) is the smallest positive k such that the digit sums of k and k + 1 are both divisible by n, or -1 if no such pair exists.
1, 19, -1, 39, 49999, -1, 69999, 79, -1, 18999999999, 2899999, -1, 48999, 5899999999999, -1, 78999999999, 8899, -1, 19899999999999999999, 298999999999, -1, 49899999, 598999999999999999999, -1, 79899999999999999, 898999, -1, 19989999999999999999999999999, 29989999999999999, -1
Offset: 1
Examples
a(2) = 19 because both 19 and 20 have digit sums that are multiples of 2: 1+9 = 10 = 5*2 and 2+0 = 2 = 1*2, it is easily checked (by exhaustion) that there is no smaller pair of consecutive integers with this property.
Links
- Colin Beveridge, Proof of formula
Programs
-
Python
def A378119(n): if n == 1: return 1 elif n % 3 == 0: return -1 else: return (((n%9)+1)*10**(n//9)-1)*(10**pow(9,-1,n))-1 # Colin Beveridge, Dec 13 2024
Formula
a(n) = A051885(n) * 10^q - 1, where q is 9^(-1) (mod n) for n > 1 and n not a multiple of 3 (see linked proof). - Colin Beveridge, Dec 16 2024
Comments