login
A273190
a(n) is the number of nonnegative m < n for which m + n is a perfect square.
3
0, 1, 0, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4
OFFSET
0,10
FORMULA
a(n) = floor(sqrt(2*n-1))-floor(sqrt(n-1)) for n > 0. - Chai Wah Wu, May 25 2016
a(n) = A103128(n) - A000196(n-1); after previous formula. - Michel Marcus, May 25 2016
a(n) = Sum_{i=1..n} c(2*n-i), where c is the square characteristic (A010052). - Wesley Ivan Hurt, Nov 26 2020
EXAMPLE
a(1) = 1 because 1 + 0 is a perfect square.
a(2) = 0 because neither 2 + 0 nor 2 + 1 are perfect squares.
a(5) = 1 because 5 + 4 is a perfect square.
a(9) = 2 because 9 + 0 and 9 + 7 are perfect squares.
MATHEMATICA
Table[Count[Range[0, n - 1], m_ /; IntegerQ@ Sqrt[m + n]], {n, 0, 120}] (* Michael De Vlieger, May 18 2016 *)
PROG
(Java)
int n = 100;
int[] terms = new int[n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < i; j++) {
if (Math.sqrt(i+j) == Math.floor(Math.sqrt(i+j))) {
terms[i]++;
}
}
System.out.print(terms[i] + ", ");
}
(PARI) a(n) = sum(k=0, n-1, issquare(n+k)); \\ Michel Marcus, May 18 2016
(Haskell) a273190 n = length $ filter (>=n) $ takeWhile (< 2 * n) $ map (^2) [1..] -- Peter Kagey, May 25 2016
(Python)
from gmpy2 import isqrt
def A273190(n):
return isqrt(2*n-1)-isqrt(n-1) if n > 0 else 0 # Chai Wah Wu, May 25 2016
CROSSREFS
Sequence in context: A072530 A184341 A090455 * A086288 A104360 A318998
KEYWORD
easy,nonn
AUTHOR
Alec Jones, May 17 2016
STATUS
approved