|
|
A062892
|
|
Number of squares that can be obtained by permuting the digits of n.
|
|
6
|
|
|
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
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,101
|
|
COMMENTS
|
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):
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
|
|
LINKS
|
|
|
FORMULA
|
|
|
EXAMPLE
|
a(169) = 3; the squares obtained by permuting the digits are 169, 196, 961.
|
|
MATHEMATICA
|
Table[t1=Table[FromDigits[k], {k, Permutations[IntegerDigits[n]]}]; p=Length[Select[t1, IntegerQ[Sqrt[#]]&]], {n, 0, 104}] (* Jayanta Basu, May 17 2013 *)
|
|
PROG
|
(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)))
|
|
CROSSREFS
|
A096599 gives the squares k^2 such that a(k^2) = 1.
|
|
KEYWORD
|
base,nonn,easy
|
|
AUTHOR
|
|
|
EXTENSIONS
|
Corrected and extended by Larry Reeves (larryr(AT)acm.org), Jul 02 2001
|
|
STATUS
|
approved
|
|
|
|