|
|
A123911
|
|
Numbers n such that if you multiply the primes that are indexed by the digits of n and add the sum of digits of n you get n.
|
|
0
|
|
|
|
OFFSET
|
1,1
|
|
COMMENTS
|
As prime(0) is not defined, n may not contain any zero digits.
|
|
LINKS
|
|
|
EXAMPLE
|
2295 is in the sequence because prime(2)*prime(2)*prime(9)*prime(5) + sum of digits of 2295 = 3*3*23*11 + (2+2+9+5) = 2277 + 18 = 2295.
|
|
MATHEMATICA
|
fQ[n_] := ! MemberQ[IntegerDigits@n, 0] && Times @@ Prime@ IntegerDigits@n + Plus @@ IntegerDigits@n == n; Do[ If[fQ@n, Print@n], {n, 2*10^9}]
|
|
PROG
|
(PARI) { a(m) = forvec(v=vector(8, i, [0, m]), u=vector(9, i, if(i<9, v[i], m)-if(i>1, v[i-1], 0) ); t=prod(i=1, 9, prime(i)^u[i])+sum(i=1, 9, u[i]*i); s=eval(Vec(Str(t))); if(#s!=m, next); w=vector(9); for(j=1, #s, if(s[j], w[s[j]]++)); if(u==w, print(t)), 1) } /* m is the length */ \\ Max Alekseyev, Feb 08 2010
(Python)
from operator import mul
from functools import reduce
from itertools import combinations_with_replacement
A123911_list, plist = [], [0]+[prime(i) for i in range(1, 10)]
for l in range(1, 30):
L = 10**(l-1)
H = 10*L
for c in combinations_with_replacement(range(1, 10), l):
n = reduce(mul, [plist[i] for i in c]) + sum(c)
if L <= n < H and sorted(int(d) for d in str(n)) == list(c):
|
|
CROSSREFS
|
|
|
KEYWORD
|
base,more,nonn
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|