OFFSET
1,5
REFERENCES
Alfred S. Posamentier, Math Charmers, Tantalizing Tidbits for the Mind, Prometheus Books, NY, 2003, page 67.
LINKS
Antti Karttunen, Table of n, a(n) for n = 1..16416
FORMULA
a(n)=0 iff n=2^k.
a(n)=1 iff n is a triangular number (A000217).
EXAMPLE
a(18) = 3 because 3+4+5+6 = 5+6+7 = 18 but 3 < 5.
MATHEMATICA
f[n_] := Block[{r = Ceiling[n/2]}, If[ IntegerQ[ Log[2, n]], 0, m = Range[r]; lst = Flatten[ Table[ m[[k]], {i, r}, {j, i + 1, r}, {k, i, j}], 1]; lst[[ Position[ Plus @@@ lst, n, 1, 1][[1, 1]], 1]]]]; Table[ f[n], {n, 93}] (* Robert G. Wilson v, Feb 25 2005 *)
PROG
(PARI) A104512(n) = if(!bitand(n, n-1), 0, my(b, d, u=1+sqrtint(2*n)); for(k=0, n-2, b = binomial(k+1, 2); forstep(j=min(n, k+u), k+2, -1, d = binomial(j+1, 2) - b; if(d==n, return(1+k), if(d<n, break)))); (0)); \\ Antti Karttunen, Mar 30 2021
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Alfred S. Posamentier (asp2(AT)juno.com) and Robert G. Wilson v, Feb 23 2005
STATUS
approved