Jesús Bellver Arnau has authored 3 sequences.
A387389
a(n) is the smallest positive integer for which there exists a strict partition that can be partitioned into two disjoint subsets with equal sum in n ways.
Original entry on oeis.org
6, 22, 32, 28, 40, 38, 36, 52, 50, 48, 46, 66, 64, 64, 62, 62, 60, 58, 56, 80, 80, 78, 78, 76, 78, 76, 74, 74, 72, 72, 70, 70, 68, 96, 66, 96, 94, 96, 92, 94, 92, 92, 90, 92, 90, 88, 88, 90, 86, 88, 86, 86, 84, 84, 84, 82, 82, 82, 80, 80, 110, 78, 112, 114
Offset: 1
a(1) = 6, because S={3,2,1} is a strict partition of 6 and there is a way to partition S into two disjoint subsets of equal sum: {3}={2,1}. It is not possible to do this for any strict partition of integers smaller than 6.
a(2) = 22, because S={7, 5, 4, 3, 2, 1} is a strict partition of 22 and there are two ways to partition S into two disjoint subsets of equal sum: {7,4}={5,3,2,1} and {7,3,1}={5,4,2}. There are no strict partitions of any smaller number for which this can be done.
a(3) = 32, because S={11, 6, 5, 4, 3, 2, 1} is a strict partition of 32 and there are three ways to partition S into two disjoint subsets of equal sum: {11,5}={6,4,3,2,1}, {11,4,1}={6,5,3,2} and {11,3,2}={6,5,4,1}. There are no strict partitions of any smaller number for which this can be done.
-
def partitions_distinct(n):
def _build(remaining, max_next):
if remaining == 0:
return [[]]
res = []
for k in range(min(remaining, max_next), 0, -1):
for tail in _build(remaining - k, k - 1):
res.append([k] + tail)
return res
return _build(n, n//2) # The biggest number in the subset can't be bigger than n/2
def count_half_subsets(partition, n):
if n % 2:
return 0
half = n // 2
dp = [0] * (half + 1)
dp[0] = 1
for x in partition:
for s in range(half, x - 1, -1):
dp[s] += dp[s - x]
return int(dp[half]/2) #-> to not count {X}={Y} and {Y}={X} as two different solutions
#---- Generate Sequence -----
max_n = 15 #number of terms
sequence = []
for n in range(1, max_n):
p_N_exists = False
N=1
while p_N_exists==False:
partes = partitions_distinct(2*N)
for p in partes:
subsets = count_half_subsets(p, 2*N)
if subsets == n:
sequence.append(2*N)
p_N_exists = True
break
N = N+1
A387388
a(n) is the maximum number of ways in which any strict partition of 2n can be partitioned into two disjoint subsets of equal sum.
Original entry on oeis.org
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 4, 7, 6, 6, 6, 6, 11, 11, 10, 10, 10, 19, 18, 18, 18, 17, 35, 33, 32, 32, 31, 31, 62, 60, 58, 57, 57, 55, 56, 108, 105, 103, 101, 100, 100, 99, 195, 191, 187, 184, 182, 181, 180, 361, 352, 344, 340, 336, 333
Offset: 1
a(2) = 0, because strict partitions of 4 are {4} and {3,1}. None of these partitions can be partitioned into two disjoint subsets of equal sum.
a(3) = 1, because strict partitions of 6 are {6}, {5,1}, {4,2} and {3,2,1}. There is one way to partition {3,2,1} into two disjoint subsets of equal sum: {3}={2,1}. For the other partitions, this cannot be done.
a(11) = 2, because among the 89 strict partitions of 22 there is {7, 5, 4, 3, 2, 1}. There are two ways to partition {7, 5, 4, 3, 2, 1} into two disjoint subsets of equal sum: {7,4}={5,3,2,1} and {7,3,1}={5,4,2}. And this cannot be done in three ways for any strict partition of 22.
-
def partitions_distinct(n):
def _build(remaining, max_next):
if remaining == 0:
return [[]]
res = []
for k in range(min(remaining, max_next), 0, -1):
for tail in _build(remaining - k, k - 1):
res.append([k] + tail)
return res
return _build(n, n//2) # The biggest number in the subset can't be bigger than n/2
def count_half_subsets(partition, n):
if n % 2:
return 0
half = n // 2
dp = [0] * (half + 1)
dp[0] = 1
for x in partition:
for s in range(half, x - 1, -1):
dp[s] += dp[s - x]
return int(dp[half]/2) #-> to not count {X}={Y} and {Y}={X} as two different solutions
#---- Generate Sequence -----
sequence = []
max_n=25 #number of terms
for N in range(1, max_n):
parts = partitions_distinct(2*N)
max_sols = 0
for p in parts:
subsets = count_half_subsets(p, 2*N)
if subsets > max_sols:
max_sols = subsets
sequence.append(max_sols)
A348226
a(n) is the smallest positive integer that when expressed in bases 2 to n, but read in base n, is always prime.
Original entry on oeis.org
2, 2, 43, 2, 45481, 2, 65484343, 186914543201, 50006393431, 2
Offset: 2
a(4) = 43, because
43 is prime
43 in base 3 is 1121 = 1*3^3 + 1*3^2 + 2*3 + 1 and
1*4^3 + 1*4^2 + 2*4 + 1 = 89, which is prime;
43 in base 2 is 101011 = 1*2^5 + 0*2^4 + 1*2^3 + 0*2^2 + 1*2^1 + 1 and
1*4^5 + 0*4^4 + 1*4^3 + 0*4^2 + 1*4^1 + 1 = 1093, which is prime;
and 43 is the smallest positive integer with this property.
a(10) = 50006393431
= 153060758677_9
= 564447201127_8
= 3420130221331_7
= 34550030320411_6
= 1304403114042211_5
= 232210213100021113_4
= 11210002000211222202121_3
= 101110100100100111010000001001010111_2;
if we read these numbers as base-10 numbers, they are all prime. And 50006393431 is the smallest positive integer with this property.
-
isok(k, n) = {for (b=2, n, if (! ispseudoprime(fromdigits(digits(k, b), n)), return (0));); return (1);}
a(n) = my(k=1); while (!isok(k, n), k++); k; \\ Michel Marcus, Oct 09 2021
-
from gmpy2 import digits, is_prime, next_prime
def A348226(n): # code assumes n <= 63 or n is prime
if is_prime(n):
return 2
p = 2
while True:
for i in range(n-1,1,-1):
s = digits(p,i)
if not is_prime(int(s,n)):
break
else:
return p
p = next_prime(p) # Chai Wah Wu, Nov 19 2021
Comments