cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A273190 a(n) is the number of nonnegative m < n for which m + n is a perfect square.

Original entry on oeis.org

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

Views

Author

Alec Jones, May 17 2016

Keywords

Examples

			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.
		

Crossrefs

Programs

  • Haskell
    a273190 n = length $ filter (>=n) $ takeWhile (< 2 * n) $ map (^2) [1..] -- Peter Kagey, May 25 2016
    
  • 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] + ", ");
    }
    
  • Mathematica
    Table[Count[Range[0, n - 1], m_ /; IntegerQ@ Sqrt[m + n]], {n, 0, 120}] (* Michael De Vlieger, May 18 2016 *)
  • PARI
    a(n) = sum(k=0, n-1, issquare(n+k)); \\ Michel Marcus, May 18 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

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