A277514 Irregular triangle read by rows: T(n,k) is the number of primes with n balanced ternary digits of which 2k+1 (3 <= 2k+1 <= n) are nonzero.
4, 6, 8, 10, 7, 35, 11, 70, 30, 7, 129, 143, 10, 191, 458, 93, 11, 262, 1112, 605, 11, 370, 2209, 2513, 273, 8, 484, 4007, 7646, 2562, 10, 595, 6683, 19361, 12878, 938, 9, 765, 10697, 42633, 47555, 10311, 11, 917, 16103, 85860, 143382, 62541, 3183
Offset: 3
Examples
When n=3 and k=1, there are the following three trits balanced ternary numbers: 5=1TT, 7=1T1, 11=11T, 13=111. All four of them are primes, so T(3,1) = 4; When n=4 and k=1, there are the following balanced ternary numbers with 2k+1=3 nonzero trits: 17=1T0T, 19=1T01, 23=10TT, 25=10T1, 29=101T, 31=1011, 35=110T, 37=1101. Among these 8 numbers, 6 of them are prime, so T(4,1) = 6. By listing the first few rows, this sequence appears as: k=1 2 3 4 n=3 4 n=4 6 n=5 8 10 n=6 7 35 n=8 11 70 30 n=9 7 129 143 n=10 10 191 458 93
Programs
-
Mathematica
(* This converts number m to balanced ternary form, stores the result in list t. *) BTDigits[m_Integer, g_] := Module[{n = m, d, sign, t = g}, If[n != 0, If[n > 0, sign = 1, sign = -1; n = -n]; d = Ceiling[Log[3, n]]; If[3^d - n <= ((3^d - 1)/2), d++]; While[Length[t] < d, PrependTo[t, 0]]; t[[Length[t] + 1 - d]] = sign; t = BTDigits[sign*(n - 3^(d - 1)), t]]; t]; (* This calculates j and k for balanced ternary form of number m. *) BTnonzeroNumofDigits[m_Integer] := Module[{n = m}, t = BTDigits[n, {}]; j = Length[t]; k = 0; Do[If[t[[i]] != 0, k++], {i, 1, j}]; k = (k - 1)/2; {j, k}]; (* This calculates the category index n as defined in A277513 for a {j,k} pair. *) IndexA277513[{j_, k_}] := Module[{m, i}, If[OddQ[j], m = (j - 1)/2; i = m^2 - m + k, m = j/2; i = m^2 - 2 m + 1 + k]]; (* This counts a(n). *) p=3;a={} ;While[p = NextPrime[p]; jk = BTnonzeroNumofDigits[p]; jk[[1]] <= 15, id = IndexA277513[jk]; While[Length[a] < id, AppendTo[a, 0]]; a[[id]]++];a
Comments