login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A161872 Smallest unhappy number in base n (or 0 if no unhappy numbers in the base). 4

%I #14 Sep 10 2021 18:29:26

%S 0,2,0,2,2,2,2,2,2,2,2,2,2,2,3,2,7,2,3,2,2,2,2,2,2,2,2,2,5,2,2,2,2,2,

%T 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,

%U 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2

%N Smallest unhappy number in base n (or 0 if no unhappy numbers in the base).

%C All positive integers are happy numbers in base 2 and base 4; they are called "happy bases". There are no other happy bases < 500,000,000.

%H Antti Karttunen, <a href="/A161872/b161872.txt">Table of n, a(n) for n = 2..10082</a>

%H Antti Karttunen, <a href="/A161872/a161872.txt">Data supplement: n, a(n) computed for n = 2..100000</a>

%H Dino Lorenzini, Mentzelos Melistas, Arvind Suresh, Makoto Suwama, and Haiyang Wang, <a href="https://arxiv.org/abs/2105.14361">Integer Dynamics</a>, arXiv:2105.14361 [math.NT], 2021.

%t Table[If[MemberQ[{2, 4}, n], 0, Block[{k = 2}, While[NestWhile[Total[IntegerDigits[#, n]^2] &, k, UnsameQ, All] == 1, k++]; k]], {n, 2, 105}] (* _Michael De Vlieger_, Nov 06 2018 *)

%o (PARI) A161872(n) = if((2==n)||(4==n),0, for(k=2, oo, my(visited = Map(), t = k); while(t!=1, if(mapisdefined(visited, t), return(k), mapput(visited, t, t)); t = vecsum(apply(d -> (d*d),digits(t,n)))))); \\ _Antti Karttunen_, Nov 06 2018

%Y Cf. A031177 (Unhappy numbers in base 10).

%K nonn

%O 2,2

%A _Jud McCranie_, Jun 20 2009

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 01:35 EDT 2024. Contains 371964 sequences. (Running on oeis4.)