A305257 If pd(x) is the product of the digits of the number x and sd(x) the sum of the digits of the number x then the sequence lists all the positive numbers n for which pd(n) = sd(n) and sd(pd(n)) = pd(sd(n)).
1, 2, 3, 4, 5, 6, 7, 8, 9, 22, 123, 132, 213, 231, 312, 321, 1124, 1142, 1214, 1241, 1412, 1421, 2114, 2141, 2411, 4112, 4121, 4211, 11133, 11222, 11313, 11331, 12122, 12212, 12221, 13113, 13131, 13311, 21122, 21212, 21221, 22112, 22121, 22211, 31113, 31131, 31311, 33111
Offset: 1
Examples
321 -> sd(321) = 3+2+1 = 6; pd(321) = 3*2*1 = 6; pd(sd(321)) = pd(6) = 6; sd(pd(321)) = sd(6) = 6.
Links
- Eric Weisstein's World of Mathematics, Additive Persistence.
- Eric Weisstein's World of Mathematics, Multiplicative Persistence.
Programs
-
Mathematica
sod[n_] := Plus@@ IntegerDigits@ n; pod[n_] := Times@@ IntegerDigits@ n; Select[ Range[10^5], pod@ # == sod@ # && pod@ sod@ # == sod@ pod@ # &] (* Giovanni Resta, May 30 2018 *)
-
PARI
pd(n) = my(d=digits(n)); factorback(d); alias(sd, sumdigits); isok(n) = my(p=pd(n), s=sd(n)); (p==s) && (sd(p) == pd(s)); \\ Michel Marcus, May 30 2018
-
Python
from math import prod def pd(x): return prod(map(int, str(x))) def sd(x): return sum(map(int, str(x))) def ok(n): return pd(n) == sd(n) and sd(pd(n)) == pd(sd(n)) print([k for k in range(1, 10**5) if ok(k)]) # Michael S. Branicky, Nov 12 2022
Comments