A236322 Number of (potentially overlapping) occurrences of n in the decimal representation of n^n.
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, 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, 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
Offset: 1
Links
- Scott R. Shannon, Table of n, a(n) for n = 1..10000 (terms 1..999 from Christian Perfect).
Crossrefs
Programs
-
Mathematica
a[n_] := Length[StringPosition @@ ToString /@ {n^n, n}]; Array[a, 99] (* Giovanni Resta, Jan 22 2014 *)
-
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
-
Python
from itertools import count def occurrences(string, sub): count = start = 0 while True: start = string.find(sub, start) + 1 if start > 0: count+=1 else: return count def a(n): return occurrences(str(n**n), str(n))
Comments