[go: up one dir, main page]

login
Number of non-overlapping occurrences of n in the decimal representation of n^n.
2

%I #22 Feb 05 2024 09:26:38

%S 1,0,0,0,1,3,0,0,1,1,2,0,0,0,0,2,1,0,2,0,2,0,0,1,2,0,0,1,0,0,2,2,2,0,

%T 3,1,1,0,1,0,1,1,1,0,3,1,0,1,1,1,1,2,2,1,0,1,1,0,1,3,2,0,1,1,0,2,0,0,

%U 0,0,1,0,1,1,2,5,2,1,2,0,3,3,2,1,0,1,0

%N Number of non-overlapping occurrences of n in the decimal representation of n^n.

%H Scott R. Shannon, <a href="/A236314/b236314.txt">Table of n, a(n) for n = 1..10000</a>

%e 6^6 is 46656 with 3 6's, hence a(6) = 3.

%t a[n_] := Length@ StringPosition[ToString[n^n], ToString[n], Overlaps -> False]; (* _Giovanni Resta_, Jan 22 2014 *)

%o (Python)

%o from itertools import count

%o a=(str(n**n).count(str(n)) for n in count(1))

%Y A049329 lists n where a(n) is nonzero.

%Y The same sequence but allowing for overlapping occurrences is at A236322.

%K base,nonn,easy

%O 1,6

%A _Christian Perfect_, Jan 22 2014