%I #29 Feb 05 2024 09:17:05
%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,0,0,0,5,1,3,4,2,2,1,1,10
%N Number of (potentially overlapping) occurrences of n in the decimal representation of n^n.
%C Differs from A236314 at n=99.
%H Scott R. Shannon, <a href="/A236322/b236322.txt">Table of n, a(n) for n = 1..10000</a> (terms 1..999 from Christian Perfect).
%t a[n_] := Length[StringPosition @@ ToString /@ {n^n, n}]; Array[a, 99] (* _Giovanni Resta_, Jan 22 2014 *)
%o (Python)
%o from itertools import count
%o def occurrences(string, sub):
%o ....count = start = 0
%o ....while True:
%o ........start = string.find(sub, start) + 1
%o ........if start > 0:
%o ............count+=1
%o ........else:
%o ............return count
%o def a(n):
%o ....return occurrences(str(n**n),str(n))
%o (PARI) a(n) = my(m=Mod(n,10^#Str(n)));(m==n=n^n)+sum(i=0,1+log(n)/log(10),m==n\=10) \\ - _M. F. Hasler_, Jan 23 2014
%Y A049329 lists n where a(n) is nonzero.
%Y Non-overlapping occurrences are counted by A236314.
%K base,nonn
%O 1,6
%A _Christian Perfect_, Jan 22 2014
|