login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A347221 Square array T(s,t), s >= 0, t >= 0, read by downward antidiagonals: T(s,t) is the number of nonnegative ordered triples (a,b,c) satisfying a+b+c <= s and a*b*c <= t. 1
1, 1, 4, 1, 4, 10, 1, 4, 10, 19, 1, 4, 10, 20, 31, 1, 4, 10, 20, 32, 46, 1, 4, 10, 20, 35, 47, 64, 1, 4, 10, 20, 35, 50, 65, 85, 1, 4, 10, 20, 35, 53, 68, 86, 109, 1, 4, 10, 20, 35, 56, 71, 89, 110, 136, 1, 4, 10, 20, 35, 56, 77, 92, 113, 137, 166 (list; table; graph; refs; listen; history; text; internal format)
OFFSET
0,3
COMMENTS
Based on the fact that there are only O(sqrt(t)) distinct integers in the set S = {floor(t/1), floor(t/2), ..., floor(t/t)} and using combinatorics by fixing the number (a) as minimum, we can easily calculate this function in O(sigma(a=1->t^(1/3)) (log_2(floor(t/a)) + floor(t/a)^(1/2))).
The complexity can be reduced to O(sigma(a=1->t^(1/3)) (log_2(floor(t/a)) + floor(t/a)^(1/3))) = O(t^(5/9)).
There are many methods that take O(t^(5/9)) steps, but not all are effective; some of them have lower complexity but use too many division and multiplication steps. Some of them use precalculation and caching to speed things up, but are not as effective as the division-free algorithm that Richard Sladkey described.
It is known that for each (a), we only need a For loop of at most K = min((s-a)/2,sqrt(t/a)) iterations. If we can somehow calculate this in O(K^(1/2)) or even O(K^(1/3)) for each (a) then it is possible to calculate in O(t^(1/3)).
We can also calculate T(s, t) in O(t^(1/3)) if this function can be calculated fast enough: g(l, r, a, t) = Sum_{p = l..r} floor(t/(a*p)) for all a such that 1 <= a <= t^(1/3).
When s is small, we can try not fixing a as minimum and get O(s * t^(1/3)) complexity. You can also make the complexity not depend on O(f(t)) and get O(s^2) complexity and this can be further improved.
When s = t, the values on the main diagonal, T(s, s), are approximately 1.5*s^2 (tested with 10^7 numbers s <= 10^9 using a power regression algorithm).
The current best known algorithm O(t^(5/9)) (with modulo for large result) can run for s <= 10^18 and t <= 10^12 under 1 second and constant memory (820ms on GNU C++17 7.3.0 codeforces and 310ms on C++14 ideone).
As far as I know, the best complexity in theory is O(t^(2/3-c+o(1))) for small c > 0. Computing this table faster is as hard as the prime counting function and/or the divisor summatory function.
LINKS
Vo Hoang Anh, O(t^(5/9)) C++ Code
MathStackExchange, Math discussion
D. H. J. Polymath, Deterministic methods to find primes, arXiv:1009.3956 [math.NT], 2012.
FORMULA
T(s,t) = Sum_{a=0..s} Sum_{b=0..s-a} Sum_{c=0..s-a-b} [a*b*c<=t], where [] is the Iverson bracket.
T(n, n) = A347252(n).
T(0, t) = A000012(t).
T(s, 0) = A005448(s).
T(s, A006501(s) + x) = A000292(s + 1), for all x >= 0.
This leads to: T(s, A000578(s) + x) = A000292(s + 1), for all x >= 0.
T(s, t) = (3s^2 + 3s) / 2 + A061201(t) + 1, for s > t + 1 > 1.
T(s, 1) = (3s^2 + 3s) / 2 + 2 = A139482(s + 2), for s > t + 1 > 1.
T(s, 2) = (3s^2 + 3s) / 2 + 5 = A124011(s), for s > t + 1 > 2.
T(s, t) = T(s + k, t) - 3*k*s - 3*A000217(k), for s > t + 1 > 5.
T(t + 2 - k, t) = T(t + 2, t) - 3*k*s - 6k + 3*A000217(k), for 0 <= 2k <= (t-1), for t > 4.
When n > 4, T(n, n) = T(n + 2, n) - 6n - 15 = A347252(n) = Sum_{k=1..n} floor(n/k)*A000005(k) + (3n^2 + 3n - 10) / 2 = A061201(n) + (3n^2 + 3n - 10) / 2 = (1/2)n(6g^2 + (6g-2)log(n) - 6g - 6g1 + log^2(n) + 2) + (3n^2)/2 + (3n)/2 - 5 + O(sqrt(n)) where g is the Euler-Mascheroni number and g1 is the first Stieltjes constant.
EXAMPLE
T(2,0) = 10: (0,0,0), (0,0,1), (0,0,2), (0,1,0), (0,1,1), (0,1,2), (0,2,0), (1,0,0), (1,0,1), (2,0,0).
T(0,1) = 1: (0,0,0).
Array T(s,t) begins:
1, 1, 1, 1, 1, 1, 1, 1, 1, ...
4, 4, 4, 4, 4, 4, 4, 4, 4, ...
10, 10, 10, 10, 10, 10, 10, 10, 10, ...
19, 20, 20, 20, 20, 20, 20, 20, 20, ...
31, 32, 35, 35, 35, 35, 35, 35, 35, ...
46, 47, 50, 53, 56, 56, 56, 56, 56, ...
64, 65, 68, 71, 77, 77, 83, 83, 84, ...
85, 86, 89, 92, 98, 101, 107, 107, 114, ...
109, 110, 113, 116, 122, 125, 134, 134, 141, ...
MATHEMATICA
Table[Function[s, Sum[Boole[a b c <= t], {a, 0, s}, {b, 0, s - a}, {c, 0, s - a - b}]][n - t], {n, 0, 10}, {t, n, 0, -1}] // Flatten (* Michael De Vlieger, Aug 25 2021 *)
PROG
(C) int T(int s, int t) { int cnt = 0; for (int a = 0; a <= s; ++a) for (int b = 0; b <= s - a; ++b) for (int c = 0; c <= s - a - b; ++c) if (a * b * c <= t) ++cnt; return cnt; }
(PARI) T(s, t) = sum(a=0, s, sum(b=0, s-a, sum(c=0, s-a-b, a*b*c <= t))); \\ Michel Marcus, Aug 25 2021
CROSSREFS
Cf. A005448 (column 0), A347252 (main diagonal).
Sequence in context: A165487 A344685 A201286 * A208527 A209576 A055886
KEYWORD
nonn,easy,tabl
AUTHOR
Vo Hoang Anh, Aug 24 2021
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified June 22 22:41 EDT 2024. Contains 373629 sequences. (Running on oeis4.)