login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Number of permutations p of 1,2,...,n such that both numerator and denominator of the continued fraction [p(1); p(2),...,p(n)] are primes.
3

%I #21 Oct 30 2022 18:19:59

%S 0,1,1,3,3,20,126,694,2874,25059,218517,2054986,21050226

%N Number of permutations p of 1,2,...,n such that both numerator and denominator of the continued fraction [p(1); p(2),...,p(n)] are primes.

%C Based on a question from _Leroy Quet_.

%e a(4)=3 because [2;1,3,4] = 47/17, [2;3,1,4] = 43/19, [4;3,1,2] = 47/11.

%t Table[Length@Select[Permutations@Range@n,And@@PrimeQ[{Denominator@#,Numerator@#}&@FromContinuedFraction@#]&],{n,9}] (* _Giorgos Kalogeropoulos_, Sep 22 2021 *)

%o (Python)

%o from itertools import permutations

%o from sympy import isprime

%o from sympy.ntheory.continued_fraction import continued_fraction_reduce

%o def A078431(n): return sum(1 for p in permutations(range(1,n+1)) if (lambda x: isprime(x.p) and isprime(x.q))(continued_fraction_reduce(p))) # _Chai Wah Wu_, Sep 22 2021

%Y Cf. A078432, A078433.

%K nonn,more

%O 1,4

%A _Reiner Martin_, Dec 30 2002

%E a(11)-a(13) from _Robert Gerbicz_, Nov 27 2010