%I #17 Dec 17 2017 03:07:03
%S 0,1,1,1,1,1,1,1,1,1,1,2,1,1,2,1,1,2,1,2,2,1,1,2,1,2,2,2,1,2,1,1,1,1,
%T 1,2,1,1,2,2,1,2,1,1,2,2,1,2,1,2,2,1,1,2,1,1,2,1,1,2,1,2,2,2,1,1,1,2,
%U 2,2,1,2,1,1,2,1,1,2,1,2,2,2,1,2,1,2,2,1,1,2,1,1,2,1,1,2,1,1,1,2,1,6,1,4,6
%N a(n) is the number of numbers k such that k is obtained by permuting the digits of n and gcd(n,k) > 1.
%C For a number like 12345 which is a multiple of three and does not contain zero, all 5! = 120 permutations yield a distinct number divisible by 3, thus a(12345) = 120. However, 120 occurs for the first time at n = 10236, which is also a multiple of three. - _Antti Karttunen_, Dec 16 2017
%H Antti Karttunen, <a href="/A091853/b091853.txt">Table of n, a(n) for n = 1..12345</a>
%e 1 is the only number obtained by permuting the digits of 1, gcd(1,1) = 1, hence a(1) = 0.
%e 001, 010, 100 are the numbers obtained by permuting the digits of 100, gcd(100,1) = 1, gcd(100,10) = 10, gcd(100,100) = 100, hence a(100) = 2.
%t Table[Count[Union@ Map[# Boole[! CoprimeQ[#, n]] &@ FromDigits@ # &, Permutations@ IntegerDigits@ n], _?(# > 0 &)], {n, 105}] (* _Michael De Vlieger_, Dec 16 2017 *)
%o (PARI) A091853(n) = { my(digs=digits(n),nd=length(digs),k,p,s = Set([])); for(j=0,nd!-1, p=numtoperm(nd, j); if(1<gcd(n,k=fromdigits(vector(nd,i,digs[p[i]]))),s = setunion(Set([k]),s))); length(s); }; \\ _Antti Karttunen_, Dec 16 2017
%Y Cf. A091854.
%K base,easy,nonn,look
%O 1,12
%A _Amarnath Murthy_, Mar 13 2004
%E Edited, corrected and extended by _Klaus Brockhaus_, Mar 16 2004
|