A181373 Least m>0 such that prime(n) divides S(m)=A007908(m)=123...m and all numbers obtained by cyclic permutations of its digits; 0 if no such m exists.
0, 2, 0, 100, 106, 120, 196, 102, 542, 400, 181, 21, 216, 372, 10446, 127, 10086, 616, 399, 1703, 196, 2009, 118, 12350, 516, 416, 13244, 884, 15462, 15146, 106, 1006942, 10762, 10814, 11634, 5808, 12408, 576, 30076, 4996, 25290, 1015092, 1108, 26874, 24036, 5994
Offset: 1
Examples
For prime(1)=2, no such m can exist (consider e.g. the initial 1 is permuted to the end), therefore a(1)=0. For prime(2)=3, we have S(2)=12 and the permutation 21 both divisible by 3, thus a(2)=2. (There are many m for which the divisibility property is satisfied; it is equivalent to 1+...+m=0 (mod 3), or equivalently the sum of all these digits is divisible by 3. Therefore, the permutations do not need to be checked.) For prime(3)=5, similar to prime(1)=2, no such m can exist. For prime(4)=7, it turns out the m=100 is the least possibility, i.e., 123...99100 and the permutations 234...991001, 345...9910012, ... 100123...99, (00)123...991, (0)123...9910 are all divisible by 7.
Links
- Chai Wah Wu, Table of n, a(n) for n = 1..4042
Programs
-
PARI
A181373(p,LIM=999,MIN=1)={ p=prime(p); p!=2 & p!=5 & for(n=MIN,LIM, my(S=eval(concat(vector(n,i,Str(i)))),L=#Str(S)-1); S%p & next; for(k=1,L, (S=[1,10^L]*divrem(S,10)) % p & next(2)); return(n)) } /* highly unoptimized code, for illustration purpose */
-
Python
from sympy import prime def A181373(n): s, p, l = '', prime(n), 0 for m in range(1,10**6): u = str(m) s += u l += len(u) t = s if not int(t) % p: for i in range(l-1): t = t[1:]+t[0] if int(t) % p: break else: return m else: return 'search limit reached.' # Chai Wah Wu, Nov 12 2015
-
Python
from itertools import count from sympy import prime def A181373(n): if n == 1 or n == 3: return 0 p, c, q, a, b = prime(n), 0, 1, 10, 10 for m in count(1): if m >= b: a = 10*a%p b *= 10 c = (c*a + m) % p q = q*a % p if not (c or (q-1)%p): return m # Chai Wah Wu, Oct 07 2023
Extensions
a(15)-a(31) from Chai Wah Wu, Nov 12 2015
a(32)-a(46) from Chai Wah Wu, Oct 06 2023
Comments