%I #2 Jun 12 2004 03:00:00
%S 1,2,3,4,5,6,7,8,13,23,46,158,227,265,316,445,1030,1045,1135,1234,
%T 1236,1273,1366,1380,1431,1454,1653,2027,2060,2116,2154,2315,2534,
%U 3160,3161,3162,3163,3164,3165,3166,3167,3226,5270,5567,5637,5783,10144,10235
%N Numbers n which when converted to some base between 2 and 9 yield a result with the same digits as n in a different order.
%H C. Seggelin, <a href="http://www.plastereddragon.com/maths/bases.htm">Interesting Base Conversions</a>.
%e a(12)=158 because 158 in base 9 is 185, a permutation of the digits of 158. a(19)=1135 because 1135 in base 6 is 5131. a(77)=30576 because 30576 in base 8 is 73560.
%p "replace all /n in the code below with backslash-n.";digListToNum := proc(L) local i, result; result := 0; for i from nops(L) to 1 by -1 do; result := result*10+L[i]; od; result; end;basePerm := proc(n) local b, nL, nbL, ok; nL := sort(convert(n,base,10));ok := false; for b from 2 to 9 do; nbL := sort(convert(n,base,b)); if nL=nbL then printf("%10d in base %2d = %10d./n",n,b,digListToNum(convert(n,base,b)));ok := true; fi; od; ok; end;basePermList := proc (endAt) local i, L; L := []; for i from 1 to endAt do; if basePerm(i) then L := [op(L),i] fi; od; L; end;basePermList(100000);
%K base,nonn
%O 1,2
%A Chuck Seggelin (barkeep(AT)plastereddragon.com), Nov 22 2003
|