login
a(n) is the least number that is a Smith number in all bases 2 to n but not in base n+1.
0

%I #18 Aug 30 2024 06:25:53

%S 15,475,1023,222,1924475,26910204,191999912,240365505,10127638898,

%T 15357419170

%N a(n) is the least number that is a Smith number in all bases 2 to n but not in base n+1.

%e a(3) = 475 = 5^2 * 19.

%e In base 2, 475 = 111011011_2 with digit sum 7, 5 = 101_2 with digit sum 2, 19 = 10011_2 with digit sum 3, and 7 = 2 * 2 + 3.

%e In base 3, 475 = 122121_3 with digit sum 9, 5 = 12_3 with digit sum 3, 19 = 201_3 with digit sum 3, and 9 = 2 * 3 + 3.

%e In base 4, 475 = 13123_4 with digit sum 10, 5 = 11_4 with digit sum 2, 19 = 103_4 with digit sum 4, and 10 <> 2 * 2 + 4.

%p f:= proc(n) local F, t,b;

%p if isprime(n) then return 0 fi;

%p F:= ifactors(n)[2];

%p for b from 2 while convert(convert(n,base,b),`+`) = add(t[2]*convert(convert(t[1],base,b),`+`), t = F) do od:

%p if b = 2 then 0 else b-1 fi

%p end proc:

%p N:= 7: # for a(2) .. a(N)

%p V:= Vector(N): count:= 0:

%p for n from 4 while count < N-1 do

%p v:= f(n);

%p if v > 0 and V[v] = 0 then V[v]:= n; count:= count+1 fi;

%p od:

%p convert(V[2..N],list);

%o (Python)

%o from sympy.ntheory import digits

%o from sympy import factorint, isprime

%o from itertools import count, islice

%o def sd(n, base=10): return sum(digits(n, base)[1:])

%o def f(n, factors):

%o for b in count(2):

%o if sd(n, base=b) != sum(sd(p, base=b)*factors[p] for p in factors):

%o break

%o return b-1

%o def agen(): # generator of terms

%o adict, n = dict(), 2

%o for k in count(1):

%o if isprime(k): continue

%o v = f(k, factorint(k))

%o if v not in adict: adict[v] = k

%o while n in adict: yield adict[n]; n += 1

%o print(list(islice(agen(), 4))) # _Michael S. Branicky_, Aug 25 2024

%o (PARI) smith(k) = {my(f = factor(k), p = f[,1], e = f[,2], b = 2); while(sumdigits(k, b) == sum(i = 1, #p, e[i] * sumdigits(p[i], b)), b++); b-1;}

%o lista(len) = {my(m = len + 1, v = vector(m), c = 0, i); forcomposite(k = 1, , i = smith(k); if(i <= m && v[i] == 0, c++; v[i] = k; if(c == m, break))); vecextract(v, "^1");} \\ _Amiram Eldar_, Aug 29 2024

%Y Cf. A006753, A278909.

%K nonn,base,more

%O 2,1

%A _Robert Israel_, Aug 25 2024

%E a(8)-a(9) from _Michael S. Branicky_, Aug 26 2024

%E a(10)-a(11) from _Amiram Eldar_, Aug 29 2024