login
A078431
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
0, 1, 1, 3, 3, 20, 126, 694, 2874, 25059, 218517, 2054986, 21050226
OFFSET
1,4
COMMENTS
Based on a question from Leroy Quet.
EXAMPLE
a(4)=3 because [2;1,3,4] = 47/17, [2;3,1,4] = 43/19, [4;3,1,2] = 47/11.
MATHEMATICA
Table[Length@Select[Permutations@Range@n, And@@PrimeQ[{Denominator@#, Numerator@#}&@FromContinuedFraction@#]&], {n, 9}] (* Giorgos Kalogeropoulos, Sep 22 2021 *)
PROG
(Python)
from itertools import permutations
from sympy import isprime
from sympy.ntheory.continued_fraction import continued_fraction_reduce
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
CROSSREFS
Sequence in context: A157050 A059368 A090694 * A346750 A292953 A292221
KEYWORD
nonn,more
AUTHOR
Reiner Martin, Dec 30 2002
EXTENSIONS
a(11)-a(13) from Robert Gerbicz, Nov 27 2010
STATUS
approved