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.

A062892 Number of squares that can be obtained by permuting the digits of n.

This page as a plain text file.
%I A062892 #26 Oct 19 2021 23:51:16
%S A062892 1,1,0,0,1,0,0,0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
%T A062892 0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,
%U A062892 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,2,0,0,0,0
%N A062892 Number of squares that can be obtained by permuting the digits of n.
%C A062892 The original definition was ambiguous (it did not specify how repeated digits or leading zeros are to be handled). Here is a precise version (based on the Mathematica code):
%C A062892 Suppose the decimal expansion of n has d digits. Apply all d! permutations, discard duplicates, but keep any with leading zeros; now ignore leading zeros; a(n) is the number of squares on the resulting list. For example, if n = 100 we end up with 100, 010, 001, and both 100 and 1 are squares, so a(100)=2. If n=108 we get 6 numbers but only (0)81 is a square, so a(108)=1. - _N. J. A. Sloane_, Jan 16 2014
%H A062892 David A. Corneth, <a href="/A062892/b062892.txt">Table of n, a(n) for n = 0..9999</a>
%F A062892 a(A096600(n))=0; a(A007937(n))>0; a(A096599(n))=1; a(A096598(n))>1. - _Reinhard Zumkeller_, Jun 29 2004
%e A062892 a(169) = 3; the squares obtained by permuting the digits are 169, 196, 961.
%t A062892 Table[t1=Table[FromDigits[k],{k,Permutations[IntegerDigits[n]]}]; p=Length[Select[t1,IntegerQ[Sqrt[#]]&]], {n,0,104}] (* _Jayanta Basu_, May 17 2013 *)
%o A062892 (PARI) a(n) = {my(d = vecsort(digits(n)), res = 0); forperm(d, p, res += issquare(fromdigits(Vec(p)))); res } \\ _David A. Corneth_, Oct 18 2021
%o A062892 (Python)
%o A062892 from math import isqrt
%o A062892 from sympy.utilities.iterables import multiset_permutations as mp
%o A062892 def sqr(n): return isqrt(n)**2 == n
%o A062892 def a(n):
%o A062892     s = str(n)
%o A062892     perms = (int("".join(p)) for p in mp(s, len(s)))
%o A062892     return len(set(p for p in perms if sqr(p)))
%o A062892 print([a(n) for n in range(105)] ) # _Michael S. Branicky_, Oct 18 2021
%Y A062892 A096599 gives the squares k^2 such that a(k^2) = 1.
%K A062892 base,nonn,easy
%O A062892 0,101
%A A062892 _Amarnath Murthy_, Jun 29 2001
%E A062892 Corrected and extended by Larry Reeves (larryr(AT)acm.org), Jul 02 2001