A277428 a(n) = the n-bit number in which the i-th bit is 1 if and only if prime(i) divides A060795(n).
0, 1, 4, 9, 11, 22, 75, 105, 449, 425, 1426, 2837, 4765, 2775, 21895, 57558, 87602, 145177, 123788, 694479, 677326, 1516496, 3363284, 2048443, 26968428, 24488513, 98733728
Offset: 1
Examples
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.
Programs
-
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; } }
-
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 *)
-
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
Extensions
a(22)-a(27) from Michael De Vlieger, Oct 19 2016
Comments