# [seqfan] Re: Symmetric Relations and Self-Inverse Permutations

Peter Pein petsie at dordos.net
Mon Apr 27 20:16:44 CEST 2009

```franktaw at netscape.net schrieb:
> I just submitted:
>
> %I A159587
> %S A159587
> 1,3,2,5,4,35,8,7,11,21,9,55,16,15,14,13,19,65,17,33,10,39,25,77,23,45,
> %T A159587
> 29,51,27,1001,32,31,20,57,6,85,41,63,22,69,37,715,47,75,26,87,43,91,53,
> %U A159587
> 93,28,95,49,115,12,99,34,111,61,1309,59,117,38,67,18,455,64,123,40,429
> %N A159587 a(n) is the smallest number not yet in the sequence with the
> same
> number of distinct prime divisors as n, but relatively prime to n.
> %C A159587 This is a self-inverse permutation of the positive integers.
> ....
>
> I'm wondering about the record highs for this sequence.

OK, here we go (Mathematica and me ;-) ):
Clear[a];
a[1] = 1;
ac = Compile[{{k, _Integer}},
Block[{d = Length[FactorInteger[k]],
an1 = a /@ Range[k - 1],
i = 2},
While[MemberQ[an1, i] || GCD[k, i] =!= 1 || Length[FactorInteger[i]] =!= d,
i++]; i],
{{d | i, _Integer}, {an1, _Integer, 1}}];
a[n_Integer /; n > 1] := a[n] = ac[n]

m = 1; r = {{1, 1}};
For[i = 1, i <= 5000, i++*If[a[i] > m, AppendTo[r, {i, m = a[i]}]]]; r

{{1, 1}, {2, 3}, {4, 5}, {6, 35}, {12, 55}, {18, 65}, {24, 77}, {30, 1001},
{60, 1309},
{90, 1463}, {120, 1547}, {150, 1729}, {180, 1771}, {210, 46189}, {420,
55913}, {630, 62491},
{840, 70499}, {1050, 75361}, {1260, 78793}, {1470, 81719}, {1680, 84227},
{1890, 89947},
{2100, 95381}, {2310, 2800733}, {4620, 2993887}}

and isn't this:

First[{{1, 1}, {2, 3}, {4, 5}, {6, 35}, {12, 55}, {18, 65}, {24, 77}, {30,
1001}, {60, 1309},
{90, 1463}, {120, 1547}, {150, 1729}, {180, 1771}, {210, 46189}, {420,
55913}, {630, 62491},
{840, 70499}, {1050, 75361}, {1260, 78793}, {1470, 81719}, {1680, 84227},
{1890, 89947},
{2100, 95381}, {2310, 2800733}, {4620, 2993887}}\[Transpose]]/3

{1/3,2/3,4/3,2,4,6,8,10,20,30,40,50,60,70,140,210,280,350,420,490,560,630,700,770,1540}

interesting?

```