A333082
Number of permutations sigma of [n] such that all values sigma(k)/k for 1 <= k <= n are pairwise distinct.
Original entry on oeis.org
1, 1, 1, 5, 13, 79, 345, 2785, 19595, 171141, 1555181, 18998391, 184988197, 2675065491, 35582840563, 490186693669
Offset: 0
-
Table[ Count[ Length[ Union[ #/ Range[n]]] & /@ Permutations[ Range@n], n], {n, 0, 9}] (* Giovanni Resta, Mar 09 2020 *)
-
def A(n)
(1..n).to_a.permutation.select{|i| (1..n).map{|j| i[j - 1] / j.to_r}.uniq.size == n}.size
end
def A333082(n)
(0..n).map{|i| A(i)}
end
p A333082(9)
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
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.
-
(* 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!}]
-
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
Showing 1-2 of 2 results.
Comments