A062892 Number of squares that can be obtained by permuting the digits of n.
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, 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, 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
Offset: 0
Examples
a(169) = 3; the squares obtained by permuting the digits are 169, 196, 961.
Links
- David A. Corneth, Table of n, a(n) for n = 0..9999
Crossrefs
A096599 gives the squares k^2 such that a(k^2) = 1.
Programs
-
Mathematica
Table[t1=Table[FromDigits[k],{k,Permutations[IntegerDigits[n]]}]; p=Length[Select[t1,IntegerQ[Sqrt[#]]&]], {n,0,104}] (* Jayanta Basu, May 17 2013 *)
-
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
-
Python
from math import isqrt from sympy.utilities.iterables import multiset_permutations as mp def sqr(n): return isqrt(n)**2 == n def a(n): s = str(n) perms = (int("".join(p)) for p in mp(s, len(s))) return len(set(p for p in perms if sqr(p))) print([a(n) for n in range(105)] ) # Michael S. Branicky, Oct 18 2021
Formula
a(A096600(n))=0; a(A007937(n))>0; a(A096599(n))=1; a(A096598(n))>1. - Reinhard Zumkeller, Jun 29 2004
Extensions
Corrected and extended by Larry Reeves (larryr(AT)acm.org), Jul 02 2001
Comments