OFFSET
1,3
COMMENTS
a(n) is also the n-bit number in which the i-th bit is 1 if and only if prime(i) does not divide A060796(n).
a(n) is also the encoding of the fraction defined as follows:
Consider the set of fractions that can be built by only using each prime number from prime(1) to prime(n) exactly once as factors, either in the numerator or in the numerator. There are 2^n such fractions. One of them, let's call it x, has the property of yielding the result nearest to 1. a(n) is the n-bit number in which the i-th bit is 1 if prime(i) appears in the numerator of x, 0 if prime(i) appears in the denominator of x.
EXAMPLE
For n = 1, two distinct fractions can be written with the first prime number, namely 1/2 and 2. Of the two, 1/2 is nearer to 1. 1/2 has its 2 below the fraction bar, so its binary encoding is 0, which yields a(1) = 0.
For n = 2, four distinct fractions can be written with the first two prime numbers, namely 1/6, 2/3, 3/2 and 6. 2/3 is the nearest to 1. 2/3 has its 2 above the fraction bar and its 3 below, so its encoding is 01, which yields a(2) = 1.
MATHEMATICA
{0}~Join~Table[Function[p, FromDigits[#, 2] &@ Reverse@ MapAt[# + 1 &, ConstantArray[0, n], Partition[#, 1, 1]] &@ PrimePi@ FactorInteger[Numerator@ #][[All, 1]] &@ Max@ Select[Map[p/#^2 &, Divisors@ p], # < 1 &]][Times @@ Prime@ Range@ n], {n, 2, 23}] (* Michael De Vlieger, Oct 19 2016 *)
PROG
(Java)
package oeis;
public class BinaryEncodedBestPrimeSetup {
// Brute force implementation... Can it be improved?
public static int PRIME[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, /* to be continued */ };
public static void main(String args[]) {
int nMax = PRIME.length; // number of terms of the sequence
for (int n = 1; n <= nMax; n ++) {
if (n > 1) {
System.out.print(", ");
}
System.out.print(u(n));
}
}
private static int u(int n) {
double bestMul = 0.0;
int bestSetup = -1;
int s = 0; // binary-encoded setup number
for (s = 0; s < (1 << n); s ++) {
double mul = 1.0;
int i = 0; // prime number #
for (i = 0; i < n; i ++) {
if ((s & (1 << i)) != 0) {
mul *= PRIME[i]; // 1 = above fraction bar
} else {
mul /= PRIME[i]; // 0 = below fraction bar
}
}
if (mul < 1.0) {
if (mul > bestMul) {
bestMul = mul;
bestSetup = s;
}
}
}
return bestSetup;
}
}
(PARI) a060795(n) = my(m=prod(i=1, n, prime(i))); divisors(m)[numdiv(m)\2];
a(n) = {my(a95 = a060795(n)); v = vector(n, i, (a95 % prime(i))==0); subst(Polrev(v), x, 2); } \\ Michel Marcus, Dec 03 2016
CROSSREFS
KEYWORD
nonn,base,more
AUTHOR
Luc Rousseau, Oct 14 2016
EXTENSIONS
a(22)-a(27) from Michael De Vlieger, Oct 19 2016
STATUS
approved