OFFSET
1,3
COMMENTS
Dick Hess gave a puzzle at a "Gathering for Gardner" meeting asking for a(40).
a(n) is the number of integers not exceeding n that are divisible by 3 plus the number of cubes in the same range that are not divisible by 3.
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..1000
FORMULA
a(n) = floor(n/3) + floor(n^(1/3)) - floor(n^(1/3)/3).
EXAMPLE
Suppose n = 40. There are 13 numbers in the range that are divisible by 3 and should be counted. In addition, there are two cubes 1 and 8 that are not divisible by 3. Thus, a(40) = 15.
MATHEMATICA
Table[Floor[n/3] + Floor[n^(1/3)] - Floor[n^(1/3)/3], {n, 100}]
Accumulate[Table[If[IntegerQ[CubeRoot[n^n]], 1, 0], {n, 100}]] (* Harvey P. Dale, Aug 12 2025 *)
PROG
(Python)
from sympy import integer_nthroot
def A371587(n): return n//3+integer_nthroot(n, 3)[0]-integer_nthroot(n//27, 3)[0] # Chai Wah Wu, Sep 18 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Tanya Khovanova, Mar 28 2024
STATUS
approved
