login
Happy Niven (or happy harshad) numbers.
1

%I #17 Jan 03 2022 23:32:09

%S 1,7,10,70,100,133,190,192,230,280,320,392,440,644,700,736,820,874,

%T 888,910,912,1000,1088,1090,1092,1122,1125,1128,1141,1148,1152,1185,

%U 1188,1212,1215,1233,1251,1274,1275,1300,1323,1330,1332,1512,1521,1547,1679,1725

%N Happy Niven (or happy harshad) numbers.

%C Numbers that are divisible by the sum of their digits and whose trajectory under iteration of sum of squares of digits map includes 1.

%H Alois P. Heinz, <a href="/A350533/b350533.txt">Table of n, a(n) for n = 1..10000</a>

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Happy_number">Happy number</a>

%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Harshad_number">Harshad number</a>

%F { A005349 } intersect { A007770 }.

%e 133 is a term because 133/7 = 19 and its trajectory under iteration of sum of squares of digits map is 133 -> 19 -> 82 -> 68 -> 100 -> 1.

%p q:= proc(n) local m, s; m, s:= n, {};

%p if irem(n, add(i, i=convert(n, base, 10)))>0 then return false fi;

%p do if m=1 then return true

%p elif m in s then return false

%p else s, m:= s union {m}, add(i^2, i=convert(m, base, 10))

%p fi

%p od

%p end:

%p select(q, [$1..2000])[];

%Y Cf. A003132, A005349, A007770.

%K nonn,base

%O 1,2

%A _Alois P. Heinz_, Jan 03 2022