A348295 a(n) = Sum_{k=1..n} (-1)^(floor(k*(sqrt(2)-1))).
0, 1, 2, 1, 0, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 3, 4, 3, 2, 1, 2, 3, 2, 1, 0, 1, 2, 1, 0, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 4, 5, 4, 3, 2, 3, 4, 3, 2, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 4, 5, 6, 5, 4, 5, 6, 5, 4, 3, 4, 5, 4, 3, 2, 3, 4, 3, 2, 3, 4, 5, 4
Offset: 0
Keywords
Examples
A097508(1)..A097508(10) = [0, 0, 1, 1, 2, 2, 2, 3, 3, 4], so a(10) = 1+1-1-1+1+1+1-1-1+1 = 2.
Links
- Jianing Song, Table of n, a(n) for n = 0..10000
- Mathematical Association of America, The 81st William Lowell Putnam Mathematical Competition Problems
- Mathematical Association of America, The 81st William Lowell Putnam Mathematical Competition Session B Solutions
- Index to sequences related to Olympiads and other Mathematical competitions.
Programs
-
Mathematica
a[n_] := Sum[(-1)^Floor[k*(Sqrt[2] - 1)], {k, 1, n}]; Array[a, 100, 0] (* Amiram Eldar, Oct 11 2021 *)
-
PARI
a(n) = sum(k=1, n, (-1)^(sqrtint(2*k^2)-k))
-
Python
from math import isqrt def A348295(n): return sum(-1 if (isqrt(2*k*k)-k) % 2 else 1 for k in range(1,n+1)) # Chai Wah Wu, Oct 12 2021
Formula
a(n) = Sum_{k=1..n} (-1)^A097508(k).
Comments