A351327 Numbers whose trajectory under iteration of the product of squares of nonzero digits map includes 1.
1, 5, 10, 11, 15, 25, 50, 51, 52, 100, 101, 105, 110, 111, 115, 125, 150, 151, 152, 205, 215, 250, 251, 255, 357, 375, 455, 500, 501, 502, 510, 511, 512, 520, 521, 525, 537, 545, 552, 554, 573, 735, 753, 1000, 1001, 1005, 1010, 1011, 1015, 1025, 1050, 1051
Offset: 1
Examples
255 is a term of the sequence: the square of the product of its nonzero digits is (2*5*5)^2=2500, the square of the product of its nonzero digits is (2*5)^2=100, and the square of the product of its nonzero digits is 1^2=1. 2 is not a term of the sequence because its trajectory under the map is 2 -> 4 -> 16 -> 36 -> 324 -> 576 -> 44100 -> 256 -> 3600 -> 324 (reached earlier), so it enters a loop and never reaches 1.
Links
- Luca Onnis, On a variant of the happy numbers and their generalizations, arXiv:2203.03381 [math.GM], 2022.
Programs
-
Maple
b:= proc() false end: q:= proc(n) local m, s; m, s:= n, {}; do if m=1 then return true elif m in s or b(m) then b(n):= true; return false else s, m:= {s[], m}, mul(max(1, i)^2, i=convert(m, base, 10)) fi od end: select(q, [$1..2000])[]; # Alois P. Heinz, Feb 11 2022
-
Mathematica
Select[Range[1000], FixedPoint[ Product[ReplaceAll[0 -> 1][IntegerDigits[#]][[i]]^2, {i, 1, Length[ReplaceAll[0 -> 1][IntegerDigits[#]]]}] &, #, 10] == 1 &]
-
PARI
f(n) = vecprod(apply(d -> if (d, d^2, 1), digits(n))) is(n) = { my (m=f(n)); while (1, if (n==1, return (1), n==m, return (0), n=f(n); m=f(f(m)))) } \\ Rémy Sigrist, Feb 11 2022
-
Python
from math import prod def psd(n): return prod(int(d)**2 for d in str(n) if d != "0") def ok(n): seen = set() while n not in seen: # iterate until fixed point or in cycle seen.add(n) n = psd(n) return n == 1 def aupto(n): return [k for k in range(1, n+1) if ok(k)] print(aupto(1205)) # Michael S. Branicky, Feb 07 2022
Comments