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.

Showing 1-10 of 24 results. Next

A000196 Integer part of square root of n. Or, number of positive squares <= n. Or, n appears 2n+1 times.

Original entry on oeis.org

0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10
Offset: 0

Views

Author

Keywords

Comments

Also the integer part of the geometric mean of the divisors of n. - Amarnath Murthy, Dec 19 2001
Number of numbers k (<= n) with an odd number of divisors. - Benoit Cloitre, Sep 07 2002
Also, for n > 0, the number of digits when writing n in base where place values are squares, cf. A007961; A190321(n) <= a(n). - Reinhard Zumkeller, May 08 2011
The least monotonic left inverse of squares, A000290. That is, the lexicographically least nondecreasing sequence a(n) such that a(A000290(n)) = n. - Antti Karttunen, Oct 06 2017

Examples

			G.f. = x + x^2 + x^3 + 2*x^4 + 2*x^5 + 2*x^6 + 2*x^7 + 2*x^8 + 3*x^9 + ...
		

References

  • Tom M. Apostol, Introduction to Analytic Number Theory, Springer-Verlag, 1976, p. 73, problem 23.
  • Lionel Levine, Fractal sequences and restricted Nim, Ars Combin. 80 (2006), 113-127.
  • Paul J. McCarthy, Introduction to Arithmetical Functions, Springer Verlag, 1986, p. 28.
  • N. J. A. Sloane and Allan Wilks, On sequences of Recaman type, paper in preparation, 2006.

Crossrefs

Programs

  • Haskell
    import Data.Bits (shiftL, shiftR)
    a000196 :: Integer -> Integer
    a000196 0 = 0
    a000196 n = newton n (findx0 n 1) where
       -- find x0 == 2^(a+1), such that 4^a <= n < 4^(a+1).
       findx0 0 b = b
       findx0 a b = findx0 (a `shiftR` 2) (b `shiftL` 1)
       newton n x = if x' < x then newton n x' else x
                    where x' = (x + n `div` x) `div` 2
    a000196_list = concat $ zipWith replicate [1,3..] [0..]
    -- Reinhard Zumkeller, Apr 12 2012, Oct 23 2010
    
  • Julia
    a(n) = isqrt(n) # Paul Muljadi, Jun 03 2024
  • Magma
    [Isqrt(n) : n in [0..100]];
    
  • Maple
    Digits := 100; A000196 := n->floor(evalf(sqrt(n)));
  • Mathematica
    Table[n, {n, 0, 20}, {2n + 1}] //Flatten (* Zak Seidov Mar 19 2011 *)
    IntegerPart[Sqrt[Range[0, 110]]] (* Harvey P. Dale, May 23 2012 *)
    Floor[Sqrt[Range[0, 99]]] (* Alonso del Arte, Dec 31 2013 *)
    a[ n_] := SeriesCoefficient[ (EllipticTheta[ 3, 0, x]  - 1) / (2 (1 - x)), {x, 0, n}]; (* Michael Somos, May 28 2014 *)
  • PARI
    {a(n) = if( n<0, 0, sqrtint(n))};
    
  • Python
    # from http://code.activestate.com/recipes/577821-integer-square-root-function/
    def A000196(n):
      if n < 0:
        raise ValueError('only defined for nonnegative n')
      if n == 0:
        return 0
      a, b = divmod(n.bit_length(), 2)
      j = 2**(a+b)
      while True:
        k = (j + n//j)//2
        if k >= j:
          return j
        j = k
    print([A000196(n)for n in range(102)])
    # Jason Kimberley, Nov 09 2016
    
  • Python
    from math import isqrt
    def a(n): return isqrt(n)
    print([a(n) for n in range(102)]) # Michael S. Branicky, Feb 15 2023
    
  • Scheme
    ;; The following implementation uses higher order function LEFTINV-LEASTMONO-NC2NC from my IntSeq-library. It returns the least monotonic left inverse of any strictly growing function (see the comment-section for the definition) and although it does not converge as fast to the result as many specialized integer square root algorithms, at least it does not involve any floating point arithmetic. Thus with correctly implemented bignums it will produce correct results even with very large arguments, in contrast to just taking the floor of (sqrt n).
    ;; Source of LEFTINV-LEASTMONO-NC2NC can be found under https://github.com/karttu/IntSeq/blob/master/src/Transforms/transforms-core.ss and the definition of A000290 is given under that entry.
    (define A000196 (LEFTINV-LEASTMONO-NC2NC 0 0 A000290)) ;; Antti Karttunen, Oct 06 2017
    

Formula

a(n) = Card(k, 0 < k <= n such that k is relatively prime to core(k)) where core(x) is the squarefree part of x. - Benoit Cloitre, May 02 2002
a(n) = a(n-1) + floor(n/(a(n-1)+1)^2), a(0) = 0. - Reinhard Zumkeller, Apr 12 2004
From Hieronymus Fischer, May 26 2007: (Start)
a(n) = Sum_{k=1..n} A010052(k).
G.f.: g(x) = (1/(1-x))*Sum_{j>=1} x^(j^2) = (theta_3(0, x) - 1)/(2*(1-x)) where theta_3 is a Jacobi theta function. (End)
a(n) = floor(A000267(n)/2). - Reinhard Zumkeller, Jun 27 2011
a(n) = floor(sqrt(n)). - Arkadiusz Wesolowski, Jan 09 2013
Sum_{n>0} 1/a(n)^s = 2*zeta(s-1) + zeta(s), where zeta is the Riemann zeta function. - Enrique Pérez Herrero, Oct 15 2013
From Wesley Ivan Hurt, Dec 31 2013: (Start)
a(n) = Sum_{i=1..n} (A000005(i) mod 2), n > 0.
a(n) = (1/2)*Sum_{i=1..n} (1 - (-1)^A000005(i)), n > 0. (End)
a(n) = sqrt(A048760(n)), n >= 0. - Wolfdieter Lang, Mar 24 2015
a(n) = Sum_{k=1..n} floor(n/k)*lambda(k) = Sum_{m=1..n} Sum_{d|m} lambda(d) where lambda(j) is Liouville lambda function, A008836. - Geoffrey Critzer, Apr 01 2015
Sum_{n>=1} (-1)^(n+1)/a(n) = log(2) (A002162). - Amiram Eldar, May 02 2023

A126024 Number of subsets of {1,2,3,...,n} whose sum is a square integer (including the empty subset).

Original entry on oeis.org

1, 2, 2, 3, 5, 7, 12, 20, 34, 60, 106, 190, 346, 639, 1183, 2204, 4129, 7758, 14642, 27728, 52648, 100236, 191294, 365827, 700975, 1345561, 2587057, 4981567, 9605777, 18546389, 35851756, 69382558, 134414736, 260658770, 505941852, 982896850
Offset: 0

Views

Author

John W. Layman, Feb 27 2007

Keywords

Examples

			The subsets of {1,2,3,4,5} that sum to a square are {}, {1}, {1,3}, {4}, {2,3,4}, {1,3,5} and {4,5}. Thus a(5)=7.
		

Crossrefs

Cf. A181522. - Reinhard Zumkeller, Oct 27 2010
Row sums of A281871.

Programs

  • Haskell
    import Data.List (subsequences)
    a126024 = length . filter ((== 1) . a010052 . sum) .
                              subsequences . enumFromTo 1
    -- Reinhard Zumkeller, Feb 22 2012, Oct 27 2010
  • Maple
    b:= proc(n, i) option remember; (m->
          `if`(n=0 or n=m, 1, `if`(n<0 or n>m, 0, b(n, i-1)+
          `if`(i>n, 0, b(n-i, i-1)))))(i*(i+1)/2)
        end:
    a:= proc(n) option remember; `if`(n<0, 0, a(n-1)+
          add(b(j^2-n, n-1), j=isqrt(n)..isqrt(n*(n+1)/2)))
        end:
    seq(a(n), n=0..50);  # Alois P. Heinz, Feb 02 2017
  • Mathematica
    g[n_] := Block[{p = Product[1 + z^i, {i, n}]},Sum[Boole[IntegerQ[Sqrt[k]]]*Coefficient[p, z, k], {k, 0, n*(n + 1)/2}]];Array[g, 35] (* Ray Chandler, Mar 05 2007 *)

Extensions

Extended by Ray Chandler, Mar 05 2007
a(0)=1 prepended by Alois P. Heinz, Jan 30 2017

A284249 Number T(n,k) of k-element subsets of [n] whose sum is a triangular number; triangle T(n,k), n>=0, 0<=k<=n, read by rows.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 1, 2, 3, 3, 1, 1, 1, 3, 4, 5, 3, 1, 1, 1, 3, 5, 8, 6, 4, 1, 1, 1, 3, 7, 12, 11, 9, 4, 1, 1, 1, 3, 9, 16, 20, 18, 11, 5, 1, 1, 1, 4, 10, 22, 32, 35, 26, 14, 5, 1, 1, 1, 4, 12, 29, 48, 61, 55, 36, 17, 6, 1, 1, 1, 4, 14, 37, 70, 100, 106, 84, 48, 21, 6, 1, 1
Offset: 0

Views

Author

Alois P. Heinz, Mar 23 2017

Keywords

Examples

			Triangle T(n,k) begins:
  1;
  1, 1;
  1, 1,  1;
  1, 2,  1,  1;
  1, 2,  2,  1,  1;
  1, 2,  3,  3,  1,   1;
  1, 3,  4,  5,  3,   1,   1;
  1, 3,  5,  8,  6,   4,   1,  1;
  1, 3,  7, 12, 11,   9,   4,  1,  1;
  1, 3,  9, 16, 20,  18,  11,  5,  1,  1;
  1, 4, 10, 22, 32,  35,  26, 14,  5,  1, 1;
  1, 4, 12, 29, 48,  61,  55, 36, 17,  6, 1, 1;
  1, 4, 14, 37, 70, 100, 106, 84, 48, 21, 6, 1, 1;
		

Crossrefs

Second and third lower diagonals give: A008619(n+1), A008747(n+1).
Row sums give A284250.
T(2n,n) gives A284251.

Programs

  • Maple
    b:= proc(n, s) option remember; expand(`if`(n=0,
          `if`(issqr(8*s+1), 1, 0), b(n-1, s)+x*b(n-1, s+n)))
        end:
    T:= n-> (p-> seq(coeff(p, x, i), i=0..n))(b(n, 0)):
    seq(T(n), n=0..16);
  • Mathematica
    b[n_, s_] := b[n, s] = Expand[If[n == 0, If[IntegerQ @ Sqrt[8*s + 1], 1, 0], b[n - 1, s] + x*b[n - 1, s + n]]];
    T[n_] := Function [p, Table[Coefficient[p, x, i], {i, 0, n}]][b[n, 0]];
    Table[T[n], {n, 0, 16}] // Flatten (*Jean-François Alcover, May 29 2018, from Maple *)

A281706 Number of sets of three positive numbers <= n whose sum is a square.

Original entry on oeis.org

0, 0, 0, 0, 1, 2, 3, 5, 8, 11, 15, 20, 26, 33, 40, 48, 57, 67, 80, 93, 107, 121, 136, 153, 172, 193, 214, 236, 259, 284, 311, 340, 371, 402, 433, 466, 501, 538, 577, 618, 661, 705, 751, 798, 847, 897, 949, 1002, 1057, 1115, 1176, 1239, 1303, 1369, 1436, 1505
Offset: 0

Views

Author

Keywords

Comments

Inspired by A278329.
a(n) >= a(n-1), first differences are nondecreasing.

Examples

			a(1) .. a(3) = 0;
a(4) = 1 since 2+3+4 = 9;
a(5) = 2 since 2+3+4 = 1+3+5 = 9;
a(6) = 3 since 2+3+4 = 1+3+5 = 1+2+6 = 9;
a(7) = 5 since a(6) = 3 plus 3+6+7 = 4+5+7 = 16;
a(8) = 8 since a(7) = 5 plus 1+7+8 = 2+6+8 = 3+5+8 = 16; etc.
		

Crossrefs

Column k=3 of A281871.

Programs

A176615 Number of edges in the graph on n vertices, labeled 1 to n, where two vertices are joined just if their labels sum to a perfect square.

Original entry on oeis.org

0, 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13, 15, 16, 17, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 49, 52, 55, 57, 59, 61, 63, 65, 68, 71, 74, 77, 80, 83, 86, 89, 91, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, 127, 131, 135, 138, 141, 144, 147, 150
Offset: 1

Views

Author

Keywords

Comments

Equivalently, number of pairs of integers 0 < i < j <= n such that i + j is a square.
Suggested by R. K. Guy

Examples

			For n = 7 the graph contains the 4 edges 1-3, 2-7, 3-6, 4-5.
		

Crossrefs

Column k=2 of A281871.

Programs

  • Maple
    b:= n-> 1+floor(sqrt(2*n-1))-ceil(sqrt(n+1)):
    a:= proc(n) option remember; `if`(n=0, 0, a(n-1)+b(n)) end:
    seq(a(n), n=1..100);  # Alois P. Heinz, Jan 30 2017
  • Mathematica
    a[n_] := Sum[Floor[Sqrt[2k-1]] - Floor[Sqrt[k]], {k, 1, n}]; Table[a[n], {n, 1, 68}] (* Jean-François Alcover, Nov 04 2011, after Pari *)
  • PARI
    a(n)=sum(k=1,sqrtint(n+1),ceil(k^2/2)-1)+sum(k=sqrtint(n+1)+1,sqrtint(2*n -1),n-floor(k^2/2))
    
  • PARI
    a(n)=sum(k=1,n,sqrtint(2*k-1)-sqrtint(k))

Formula

Asymptotically, a(n) ~ (2*sqrt(2) - 2)/3 n^(3/2). The error term is probably O(n^(1/2)); O(n) is easily provable.

A281872 Number of sets of exactly n positive integers <= 2n having a square element sum.

Original entry on oeis.org

1, 1, 1, 3, 8, 24, 74, 238, 786, 2646, 9071, 31536, 110967, 394420, 1414053, 5107523, 18568628, 67894564, 249513890, 921134164, 3414439996, 12703212213, 47419589969, 177551521838, 666655929561, 2509526456940, 9469082269965, 35807434636137, 135681047696427
Offset: 0

Views

Author

Alois P. Heinz, Jan 31 2017

Keywords

Examples

			a(0) = 1: {}.
a(1) = 1: {1}.
a(2) = 1: {1,3}.
a(3) = 3: {1,2,6}, {1,3,5}, {2,3,4}.
a(4) = 8: {1,2,5,8}, {1,2,6,7}, {1,3,4,8}, {1,3,5,7}, {1,4,5,6}, {2,3,4,7}, {2,3,5,6}, {4,6,7,8}.
		

Crossrefs

Formula

a(n) = A281871(2n,n).

A281864 Number of sets of exactly four positive integers <= n having a square element sum.

Original entry on oeis.org

0, 0, 2, 5, 8, 14, 23, 34, 49, 69, 93, 123, 160, 204, 255, 315, 383, 462, 554, 658, 775, 904, 1046, 1205, 1384, 1581, 1797, 2031, 2282, 2556, 2857, 3183, 3535, 3913, 4316, 4748, 5211, 5706, 6235, 6798, 7393, 8025, 8696, 9406, 10159, 10956, 11793, 12673, 13599
Offset: 4

Views

Author

Alois P. Heinz, Feb 01 2017

Keywords

Examples

			a(6) = 2: {1,4,5,6}, {2,3,5,6}.
a(7) = 5: {1,2,6,7}, {1,3,5,7}, {1,4,5,6}, {2,3,4,7}, {2,3,5,6}.
a(8) = 8: {1,2,5,8}, {1,2,6,7}, {1,3,4,8}, {1,3,5,7}, {1,4,5,6}, {2,3,4,7}, {2,3,5,6}, {4,6,7,8}.
		

Crossrefs

Column k=4 of A281871.

Programs

  • Maple
    b:= proc(n, i, t) option remember;
          `if`(i(t+1)*(2*i-t)/2, 0,
          `if`(i>n, 0, b(n-i, i-1, t-1))+b(n, i-1, t))))
        end:
    a:= proc(n) option remember; `if`(n<0, 0, a(n-1)+add(
           b(j^2-n, n-1, 3), j=isqrt(n-6)..isqrt(4*n-6)))
        end:
    seq(a(n), n=4..60);
  • Mathematica
    Table[Count[Subsets[Range[n],{4}],?(IntegerQ[Sqrt[Total[#]]]&)],{n,4,60}] (* _Harvey P. Dale, Mar 06 2019 *)

A281865 Number of sets of exactly five positive integers <= n having a square element sum.

Original entry on oeis.org

0, 1, 2, 6, 13, 24, 43, 71, 110, 166, 242, 341, 469, 633, 838, 1091, 1400, 1774, 2219, 2745, 3364, 4089, 4933, 5904, 7015, 8279, 9713, 11338, 13172, 15230, 17524, 20071, 22895, 26025, 29485, 33294, 37472, 42040, 47026, 52463, 58383, 64816, 71785, 79318, 87444
Offset: 5

Views

Author

Alois P. Heinz, Feb 01 2017

Keywords

Examples

			a(6) = 1: {1,2,3,4,6}.
a(7) = 2: {1,2,3,4,6}, {3,4,5,6,7}.
a(8) = 6: {1,2,3,4,6}, {1,3,6,7,8}, {1,4,5,7,8}, {2,3,5,7,8}, {2,4,5,6,8}, {3,4,5,6,7}.
		

Crossrefs

Column k=5 of A281871.

Programs

  • Maple
    b:= proc(n, i, t) option remember;
          `if`(i(t+1)*(2*i-t)/2, 0,
          `if`(i>n, 0, b(n-i, i-1, t-1))+b(n, i-1, t))))
        end:
    a:= proc(n) option remember; `if`(n<0, 0, a(n-1)+add(
           b(j^2-n, n-1, 4), j=isqrt(n-10)..isqrt(5*n-10)))
        end:
    seq(a(n), n=5..60);

A281866 Number of sets of exactly six positive integers <= n having a square element sum.

Original entry on oeis.org

0, 1, 3, 7, 19, 39, 74, 134, 227, 365, 568, 854, 1247, 1777, 2479, 3392, 4562, 6043, 7898, 10194, 13010, 16428, 20547, 25474, 31330, 38248, 46370, 55846, 66843, 79544, 94161, 110917, 130044, 151782, 176391, 204159, 235410, 270487, 309744, 353539, 402255
Offset: 6

Views

Author

Alois P. Heinz, Feb 01 2017

Keywords

Examples

			a(7) = 1: {1,2,4,5,6,7}.
a(8) = 3: {1,2,3,4,7,8}, {1,2,3,5,6,8}, {1,2,4,5,6,7}.
		

Crossrefs

Column k=6 of A281871.

Programs

  • Maple
    b:= proc(n, i, t) option remember;
          `if`(i(t+1)*(2*i-t)/2, 0,
          `if`(i>n, 0, b(n-i, i-1, t-1))+b(n, i-1, t))))
        end:
    a:= proc(n) option remember; `if`(n<0, 0, a(n-1)+add(
           b(j^2-n, n-1, 5), j=isqrt(n-15)..isqrt(6*n-15)))
        end:
    seq(a(n), n=6..60);

A281867 Number of sets of exactly seven positive integers <= n having a square element sum.

Original entry on oeis.org

0, 0, 4, 10, 25, 60, 124, 238, 435, 750, 1237, 1973, 3047, 4574, 6706, 9624, 13546, 18742, 25533, 34292, 45469, 59585, 77238, 99127, 126048, 158897, 198713, 246663, 304057, 372374, 453245, 548479, 660104, 790372, 941770, 1117035, 1319141, 1551314, 1817124
Offset: 7

Views

Author

Alois P. Heinz, Feb 01 2017

Keywords

Examples

			a(9) = 4: {1,2,3,6,7,8,9}, {1,2,4,5,7,8,9}, {1,3,4,5,6,8,9}, {2,3,4,5,6,7,9}.
		

Crossrefs

Column k=7 of A281871.

Programs

  • Maple
    b:= proc(n, i, t) option remember;
          `if`(i(t+1)*(2*i-t)/2, 0,
          `if`(i>n, 0, b(n-i, i-1, t-1))+b(n, i-1, t))))
        end:
    a:= proc(n) option remember; `if`(n<0, 0, a(n-1)+add(
           b(j^2-n, n-1, 6), j=isqrt(n-21)..isqrt(7*n-21)))
        end:
    seq(a(n), n=7..60);
Showing 1-10 of 24 results. Next