cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A356187 Number of permutations f of {1,...,n} with f(1) = 1 such that those k*f(k) + 1 (k = 1..n) are n distinct primes.

Original entry on oeis.org

1, 1, 0, 0, 0, 2, 2, 6, 4, 24, 6, 162, 330, 1428, 1632
Offset: 1

Views

Author

Zhi-Wei Sun, Jul 28 2022

Keywords

Comments

Conjecture: a(n) > 0 except for n = 3,4,5. Also, for any integer n > 5, there is a permutation f of {1,...,n} with f(1) = 3 such that those k*f(k) - 1 (k = 1..n) are n distinct primes.
This is stronger than part (i) of the conjecture in A321597.

Examples

			a(7) = 2 since the only permutations f of {1,...,7} with f(1) = 1 such that {k*f(k) + 1: k = 1..7} is a set of 7 primes, are (f(1),...,f(7)) = (1,3,4,7,2,5,6) and (1,5,2,3,6,7,4). Note that 1*1 + 1 = 2, 2*3 + 1 = 7, 3*4 + 1 = 13, 4*7 + 1 = 29, 5*2 + 1 = 11, 6*5 + 1 = 31, 7*6+1 = 43 are distinct primes. Also, 1*1 + 1 = 2, 2*5 + 1 = 11, 3*2 + 1 = 7, 4*3 + 1 = 13, 5*6 + 1 = 31, 6*7 + 1 = 43, 7*4 + 1 = 29 are distinct primes.
a(10) > 0 since for (f(1),...,f(10)) = (1,3,4,7,8,5,6,9,2,10) the set {k*f(k) + 1: k = 1..10} is a set of 10 distinct primes.
		

Crossrefs

Programs

  • Mathematica
    (* A program to find all the permutations f of {1,...,9} with f(1) = 1 such that U = {k*f(k)+1: k = 1..9} is a set of 9 distinct primes. *)
    V[i_]:=V[i]=Part[Permutations[{2,3,4,5,6,7,8,9}],i]
    m=0;Do[U={2};Do[p=j*V[i][[j-1]]+1;If[PrimeQ[p],U=Append[U,p]],{j,2,9}];
    If[Length[Union[U]]==9,m=m+1;Print[m," ",V[i]," ",U]],{i,1,8!}]
  • Python
    from itertools import permutations as perm
    from itertools import islice
    from sympy import isprime
    from math import factorial as fact
    import collections
    def consume(iterator, n=None):
        "Advance the iterator n-steps ahead. If n is None, consume entirely."
        # Use functions that consume iterators at C speed.
        if n is None:
            # feed the entire iterator into a zero-length deque
            collections.deque(iterator, maxlen=0)
        else:
            # advance to the empty slice starting at position n
            next(islice(iterator, n, n), None)
    for x in range(2,20):
        mult = range(1,x)
        count = 0
        q = perm(range(1,x))
        for y in q:
            keeppos = 0
            keepflag = False
            if y[0] != 1:#stop when the first digit is not 1
                break
            z = [mult[a] * y[a] + 1 for a in range(x-1)]
            for b in z[0:-2]:
                if not isprime(b):
                    keeppos = z.index(b)
                    keepflag = True
                    break
            if keepflag:#skip ahead to advance the next non-prime term
                consume(q,fact(x-keeppos-2)-1)
            elif len(set(z)) == len(z) and all(isprime(b) for b in set(z)):#no duplicates and all primes
                count += 1
        print(x-1,count)
    # David Consiglio, Jr., Aug 04 2022

Extensions

a(11)-a(13) from Jinyuan Wang, Jul 29 2022
a(14)-a(15) from David Consiglio, Jr., Aug 04 2022