cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A081355 Levenshtein distance between n and n^2 in decimal representation.

This page as a plain text file.
%I A081355 #9 Jul 21 2015 00:23:41
%S A081355 0,0,1,1,2,1,1,2,2,2,1,1,2,2,2,2,2,3,3,3,2,2,3,2,3,1,2,2,2,3,2,2,3,4,
%T A081355 4,3,3,3,4,4,3,3,4,3,4,3,3,4,4,3,2,3,4,4,4,3,3,4,4,4,2,3,4,3,4,3,3,4,
%U A081355 3,3,3,3,4,3,3,3,2,4,3,4,3,3,3,3,4,3,3,4,4,3,3,3,4,4,4,2,2,3,3,3,2,2,3,3,3
%N A081355 Levenshtein distance between n and n^2 in decimal representation.
%H A081355 Michael Gilleland, <a href="http://www.merriampark.com/ld.htm">Levenshtein Distance</a>. [It has been suggested that this algorithm gives incorrect results sometimes. - _N. J. A. Sloane_]
%t A081355 levenshtein[s_List, t_List] := Module[{d, n = Length@s, m = Length@t}, Which[s === t, 0, n == 0, m, m == 0, n, s != t, d = Table[0, {m + 1}, {n + 1}]; d[[1, Range[n + 1]]] = Range[0, n]; d[[Range[m + 1], 1]] = Range[0, m]; Do[ d[[j + 1, i + 1]] = Min[d[[j, i + 1]] + 1, d[[j + 1, i]] + 1, d[[j, i]] + If[ s[[i]] === t[[j]], 0, 1]], {j, m}, {i, n}]; d[[ -1, -1]] ]];
%t A081355 f[n_] := levenshtein[IntegerDigits[n], IntegerDigits[n^2]]; Table[f[n], {n, 0, 104}] (* _Robert G. Wilson v_, Jan 25 2006 *)
%Y A081355 Cf. A081356, A002061, A000290, A081230.
%K A081355 nonn,base
%O A081355 0,5
%A A081355 _Reinhard Zumkeller_, Mar 18 2003