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.

Previous Showing 31-40 of 46 results. Next

A174806 a(n) = n-floor(sqrt(n))^2-floor(sqrt(n-floor(sqrt(n))^2))^2; difference between n and sum of two largest distinct squares <= n.

Original entry on oeis.org

0, 0, 0, 1, 0, 0, 1, 2, 0, 0, 0, 1, 2, 0, 1, 2, 0, 0, 1, 2, 0, 1, 2, 3, 4, 0, 0, 1, 2, 0, 1, 2, 3, 4, 0, 1, 0, 0, 1, 2, 0, 1, 2, 3, 4, 0, 1, 2, 3, 0, 0, 1, 2, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 0, 0, 1, 2, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 6, 0, 0, 0, 1, 2, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 0, 0, 1, 2, 0
Offset: 0

Views

Author

Keywords

Comments

If a(n)=0 then n is a sum of two squares A001481, but not conversely. For the sum of two squares n = 18, 32, 41, ... we have a(n) > 0. - Thomas Ordowski, Jul 11 2014

Examples

			24=4^2+8;8-2^2=4, 115=10^2+15;15-3^2=6,..
		

Crossrefs

Programs

  • Mathematica
    a[n_]:=n-Floor[Sqrt[n]]^2-Floor[Sqrt[n-Floor[Sqrt[n]]^2]]^2;
    Table[a[n], {n,0,6!}]
  • PARI
    a(n) = my(x=sqrtint(n)^2); n - x - sqrtint((n-x))^2; \\ Michel Marcus, Dec 17 2022

Formula

a(n) = 0 iff A053610(n) < 3 and 0 < a(n) = m^2 iff A053610(n) = 3. - Thomas Ordowski, Jul 12 2014

A227453 Numbers k such that the distance to the largest square less than k is a multiple of 4.

Original entry on oeis.org

8, 13, 20, 24, 29, 33, 40, 44, 48, 53, 57, 61, 68, 72, 76, 80, 85, 89, 93, 97, 104, 108, 112, 116, 120, 125, 129, 133, 137, 141, 148, 152, 156, 160, 164, 168, 173, 177, 181, 185, 189, 193, 200, 204, 208, 212, 216, 220, 224, 229, 233, 237, 241, 245, 249, 253, 260, 264, 268, 272, 276, 280
Offset: 1

Views

Author

Ralf Stephan, Sep 22 2013

Keywords

Comments

A071797(a(n)) = 4*m, A053186(a(n)+1) = 4*m, m > 0.
Apparently a bisection of A079896. While it may not be difficult to prove that the sequence is a subsequence of A079896, the apparent fact that a(n) = A079896(2n-1) is by no means obvious.

Examples

			8 - 2^2 = 1*4 and 24 - 4^2 = 2*4 so 8 and 24 are in the sequence.
		

Crossrefs

Programs

  • Mathematica
    lsm4Q[n_]:=Module[{s=Floor[Sqrt[n]]^2},sHarvey P. Dale, Jun 20 2014 *)
  • PARI
    is(n)=(n-sqrtint(n-1)^2)%4==0

A305615 Next term is the largest earlier term that would not create a repetition of an earlier subsequence of length 2, if such a number exists; otherwise it is the smallest nonnegative number not yet in the sequence.

Original entry on oeis.org

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

Views

Author

Luc Rousseau, Jun 06 2018

Keywords

Comments

The map n |-> (a(n), a(n+1)) is a bijection between N and N X N: when drawn in a 2D array, this map makes progress by finishing the filling of a square gnomon before starting to fill the next one. This and the predictable zigzag way each gnomon is filled make it possible to deduce a closed formula for a(n).
A269501 is an essentially identical sequence: a(n) = A269501(n)-1. - N. J. A. Sloane, Jul 03 2018
For n > 3 indices for values = 1 are A008865(m), m > 2. - Bill McEachen, Oct 26 2023

Examples

			a(0): no already-used value exists, so one has to take the least nonnegative integer, so a(0) = 0;
a(1): reusing 0 is legal, so a(1) = 0. Repeating (0, 0) now becomes illegal;
a(2): reusing 0 is illegal since (a(1), a(2)) would repeat (0, 0). The smallest unused value is 1, so a(2) = 1. Repeating (0, 1) becomes illegal;
a(3): reusing 1 is legal. a(3) = 1. Repeating (1, 1) becomes illegal;
a(4): reusing 1 is illegal (would repeat (1, 1)) but reusing 0 is legal. a(4) = 0. Repeating (1, 0) becomes illegal;
and so on.
a(n) is also the x-coordinate of the cell that contains n in the following 2D infinite array:
  y
  ^
  |
  4 |... ... ... ... ...
    +---------------+
  3 | 9  14  12  10 |...
    +-----------+   |
  2 | 4   7   5 |11 |...
    +-------+   |   |
  1 | 1   2 | 6 |13 |...
    +---+   |   |   |
  0 | 0 | 3 | 8 |15 |...
    +---+---+---+---+---
      0   1   2   3   4 --->x
		

Crossrefs

For the 2D array shown in the EXAMPLE section, see A316323 and A269780. - N. J. A. Sloane, Jul 03 2018

Programs

  • Mathematica
    A[n_] := Module[{k, t}, k = Floor[Sqrt[n]]; t = n - k^2;
      Boole[t != 0]*k - Boole[OddQ[t]]*(t - 1)/2]; Table[A[n], {n, 0, 100}]
  • PARI
    a(n)=k=floor(sqrt(n));t=n-k^2;(t!=0)*k-(t%2)*(t-1)/2
    for(n=0,100,print1(a(n),", "))
  • Prolog
    main :- a(100, A, , ), reverse(A, R), writeln(R).
    a(0, [0], [0], []) :- !.
    a(N, A, V, P) :-
      M is N - 1, a(M, AA, VV, PP), AA = [AM | _],
      findall(L, (member(L, VV), not(member([AM, L], PP))), Ls),
      (Ls = [L | _] -> V = VV ; (length(VV, L), V = [L | VV])),
      A = [L | AA], P = [[AM, L] | PP].
    

Formula

a(n) = [t!=0]*k-[t is odd]*(t-1)/2, where k = floor(sqrt(n)), t = n-k^2 and [] stands for the Iverson bracket.

A060511 Hexagonal excess: smallest amount by which n exceeds a hexagonal number (2k^2-k, A000384).

Original entry on oeis.org

0, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
Offset: 0

Views

Author

Henry Bottomley, Mar 22 2001

Keywords

Examples

			a(19)=4 since 15(=2*3^2-3) is the largest hexagonal less than or equal to 19 and 19-15=4.
		

Crossrefs

Programs

  • Mathematica
    Flatten[Range[#]&/@Differences[Array[#(2#-1)&,10,0]]-1] (* Harvey P. Dale, Jun 05 2013 *)

A072690 a(n) = (n - A048760(n)) * (A048761(n) - n).

Original entry on oeis.org

0, 2, 2, 0, 4, 6, 6, 4, 0, 6, 10, 12, 12, 10, 6, 0, 8, 14, 18, 20, 20, 18, 14, 8, 0, 10, 18, 24, 28, 30, 30, 28, 24, 18, 10, 0, 12, 22, 30, 36, 40, 42, 42, 40, 36, 30, 22, 12, 0, 14, 26, 36, 44, 50, 54, 56, 56, 54, 50, 44, 36, 26, 14, 0, 16, 30, 42, 52, 60, 66, 70, 72, 72, 70, 66
Offset: 1

Views

Author

Reinhard Zumkeller, Jul 02 2002

Keywords

Comments

a(n)=0 iff n is a square.

Crossrefs

a(n) = A053186(n) * A068527(n).

Formula

a(n) = A053186(n) * (A072689(n) - A053186(n)).

A263651 Numbers n such that the difference between n and the largest square less than n is a nonzero square.

Original entry on oeis.org

2, 5, 8, 10, 13, 17, 20, 26, 29, 34, 37, 40, 45, 50, 53, 58, 65, 68, 73, 80, 82, 85, 90, 97, 101, 104, 109, 116, 122, 125, 130, 137, 145, 148, 153, 160, 170, 173, 178, 185, 194, 197, 200, 205, 212, 221, 226, 229, 234, 241, 250, 257, 260, 265, 272, 281, 290, 293, 298, 305
Offset: 1

Views

Author

Eli Jaffe, Oct 22 2015

Keywords

Comments

Numbers n such that A053186(n) is a positive square. - Michel Marcus, Oct 23 2015
Numbers of the form a^2 + b^2 where a >= 1 and 1 <= b^2 <= 2a. - Robert Israel, Oct 23 2015
Numbers n such that A053610(n) = 2. - Thomas Ordowski, May 22 2016

Examples

			For n=5, the largest square less than 5 is 4, and the difference between 4 and 5 is 1, which is also square.
		

Crossrefs

Cf. A053186.

Programs

  • Maple
    N:= 1000: # to get all terms <= N
    sort([seq(seq(a^2 + b^2, b=1..min(floor(sqrt(2*a)),floor(sqrt(N-a^2)))),a=1..floor(sqrt(N-1)))]); # Robert Israel, Oct 23 2015
  • Mathematica
    Select[Range@ 305, And[IntegerQ@ Sqrt[# - Floor[Sqrt@ #]^2], ! IntegerQ@ Sqrt@ #] &] (* Michael De Vlieger, Oct 23 2015 *)
  • PARI
    isok(n) = (d = (n - sqrtint(n)^2)) && issquare(d); \\ Michel Marcus, Oct 23 2015

Extensions

More terms from Michel Marcus, Oct 23 2015

A267654 Irregular triangle of palindromic subsequences. Every row has 2*n+1 terms. From the second row, there are only two alternated numbers: 2*n+4 and 2*n+2.

Original entry on oeis.org

2, 4, 2, 4, 6, 4, 6, 4, 6, 8, 6, 8, 6, 8, 6, 8, 10, 8, 10, 8, 10, 8, 10, 8, 10, 12, 10, 12, 10, 12, 10, 12, 10, 12, 10, 12, 14, 12, 14, 12, 14, 12, 14, 12, 14, 12, 14, 12, 14, 16, 14, 16, 14, 16, 14, 16, 14, 16, 14, 16, 14, 16, 14, 16
Offset: 0

Views

Author

Paul Curtz, Jan 19 2016

Keywords

Comments

Row sums = 2, 10, 26, 50, ... = A069894(n).
Starting from A053186(n) =
0, for b(n)
0, 1, 2, for c(n)
0, 1, 2, 3, 4, for d(n)
0, 1, 2, 3, 4, 5, 6,
etc,
a(n) is used for
1) b(n+1) = b(n) + (a(0)=2) i.e. 0, 2, 4, 6, ... = A005843(n).
2) c(n+3) = c(n) + (period 3:repeat 4, 2, 4) i.e. 0, 1, 2, 4, 3, 6, 8, ... = A265667(n).
3) d(n+5) = d(n) + (period 5:repeat 6, 4, 6, 4, 6) i.e. 0, 1, 2, 3, 4, 6, 5, 8, 7, 10, ... = A265734(n).
Etc.
a(n) has a companion with the same terms,differently distributed,yielding permutations of the nonnegative numbers. See A265672.
a(n) other writing (by pairs):
2, 4, 2, 4,
6, 4, 6, 4,
6, 8, 6, 8, 6, 8, 6, 8,
10 8, 10, 8, 10, 8, 10, 8,
10, 12, 10, 12, 10, 12, 10, 12, 10, 12, 10, 12,
14, 12, 14, 12, 14, 12, 14, 12, 14, 12, 14, 12,
etc.
First column: A168276(n+2). Second column: A168273(n+2).
Row sums: 12, 20, 56, 72, ... = 4*A074378(n+1).
The last term of the successive rows is the number of their terms.
Main diagonal: A005843(n+1).

Examples

			The triangle is
2,
4, 2, 4,
6, 4, 6, 4, 6,
8, 6, 8, 6, 8, 6, 8,
etc.
		

Crossrefs

Programs

  • Mathematica
    Table[2 (n - 1) + 2 (Boole@ OddQ@ k + 1), {n, 0, 7}, {k, 2 n + 1}] // Flatten (* Michael De Vlieger, Jan 19 2016 *)

Formula

a(n) = 2 * A086520(n+2).
a(2n) = 4*n + 2 times 4*n + 2 = 2, 2, 6, 6, 6, 6, 6, 6, 10,....
a(2n+1) = 4*(n+1) times 4*(n+1) = 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 12, ....

A293497 Triangular array read by rows: row n >= 1 is the list of integers from 0 to 2n-1.

Original entry on oeis.org

0, 1, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8
Offset: 0

Views

Author

Luc Rousseau, Oct 10 2017

Keywords

Comments

a(n) = the least nonnegative n - 2 * T, where T is a triangular number.
a(n) = the least nonnegative n - k * (k + 1), where k is a nonnegative integer.
This sequence shares several properties with A053186 (square excess of n):
- same recursion formula a(n) = f(n,1) with f(n,m) = if n < m then n, otherwise f(n-m,m+2);
- same formula pattern a(n) = n - g(floor(f(n))), with f and g each other's inverse function: f(x)=sqrt(x) and g(x)=x^2 in the case of A053186, f(x)=(sqrt(1+4x)-1)/2 and g(x)=x(x+1) in the case of this sequence;
- similar graphic representation (arithmetically increasing sawtooth shape);
- both sequences appear to intertwine into A288969.
Odd-indexed rows of A002262. - Omar E. Pol, Oct 10 2017

Examples

			Triangle begins:
0, 1;
0, 1, 2, 3;
0, 1, 2, 3, 4, 5;
0, 1, 2, 3, 4, 5, 6, 7;
0, 1, 2, 3, 4, 5, 6, 7, 8, 9;
...
		

Crossrefs

Programs

  • Mathematica
    FOdd[x_] := x*(x + 1)
    InvFOdd[x_] := (Sqrt[1 + 4 x] - 1)/2
    GOdd[n_] := n - FOdd[Floor[InvFOdd[n]]]
    Table[GOdd[n], {n, 0, 80}]

Formula

a(n) = n - g(floor(f(n))), with f(x) = (sqrt(1+4x)-1)/2 and g(x) = x(x+1).
a(n) = f(n,1) with f(n,m) = if n < m then n, otherwise f(n-m,m+2).
a(n) = t - t^2 + n, where t = floor(sqrt(n+1) + 1/2). - Ridouane Oudra, May 03 2019

A331478 Irregular triangle T(n,k) = n - (s - k + 1)^2 for 1 <= k <= s, with s = floor(sqrt(n)).

Original entry on oeis.org

0, 1, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 0, 5, 8, 1, 6, 9, 2, 7, 10, 3, 8, 11, 4, 9, 12, 5, 10, 13, 6, 11, 14, 0, 7, 12, 15, 1, 8, 13, 16, 2, 9, 14, 17, 3, 10, 15, 18, 4, 11, 16, 19, 5, 12, 17, 20, 6, 13, 18, 21, 7, 14, 19, 22, 8, 15, 20, 23, 0, 9, 16, 21, 24, 1
Offset: 1

Views

Author

Michael De Vlieger, Jan 17 2020

Keywords

Comments

Row n begins with n - floor(sqrt(n)).
Zero appears in row n for n that are perfect squares. Let r = sqrt(n). For perfect square n, there exists a partition of n that consists of a run of r parts that are each r themselves; e.g., for n = 4, we have {2, 2}, for n = 9, we have {3, 3, 3}. It is clear through the Ferrers diagram of these partitions that they are equivalent to their Durfee square, thus n - s^2 = 0.
Since the partitions of any n contain Durfee squares in the range of 1 <= s <= floor(sqrt(n)) (with perfect square n also including k = 0), the distinct Durfee square excesses must be the differences n - s^2 for 1 <= s <= floor(sqrt(n)).
We borrow the term "square excess" from A053186(n), which is simply the difference n - floor(sqrt(n)).
Row n of this sequence contains distinct Durfee square excesses among all integer partitions of n (see example below).

Examples

			Table begins:
   1:  0;
   2:  1;
   3:  2;
   4:  0,  3;
   5:  1,  4;
   6:  2,  5;
   7:  3,  6;
   8:  4,  7;
   9:  0,  5,  8;
  10:  1,  6,  9;
  11:  2,  7, 10;
  12:  3,  8, 11;
  13:  4,  9, 12;
  14:  5, 10, 13;
  15:  6, 11, 14;
  16:  0,  7, 12, 15;
  ...
For n = 4, the partitions are {4}, {3, 1}, {2, 2}, {2, 1, 1}, {1, 1, 1, 1}. The partition {2, 2} has Durfee square s = 2; for all partitions except {2, 2}, we have Durfee square with s = 1. Therefore we have two unique solutions to n - s^2 for n = 4, i.e., {0, 3}, so row 4 contains these values.
		

Crossrefs

Programs

  • Mathematica
    Array[# - Reverse@ Range[Sqrt@ #]^2 &, 625] // Flatten

Formula

Let s = floor(sqrt(n));
T(n,1) = A053186(n) = n - s;
T(n,k) = T(n,1) + partial sums of 2(s - k + 1) + 1 for 2 <= k <= s + 1.
A000196(n) = Length of row n.
A022554(n) = Sum of row n.
Last term in row n = T(n, A000196(n)) = n - 1.

A350178 Take n and subtract the greatest square less than or equal to n. Repeat this process until 0 is reached. a(n) is the sum of all residues after subtractions.

Original entry on oeis.org

0, 0, 1, 3, 0, 1, 3, 6, 4, 0, 1, 3, 6, 4, 6, 9, 0, 1, 3, 6, 4, 6, 9, 13, 12, 0, 1, 3, 6, 4, 6, 9, 13, 12, 9, 11, 0, 1, 3, 6, 4, 6, 9, 13, 12, 9, 11, 14, 18, 0, 1, 3, 6, 4, 6, 9, 13, 12, 9, 11, 14, 18, 17, 20, 0, 1, 3, 6, 4, 6, 9, 13, 12, 9, 11, 14, 18, 17, 20, 24, 16, 0, 1, 3, 6, 4, 6, 9, 13
Offset: 0

Views

Author

Thomas Scheuerle, Dec 18 2021

Keywords

Comments

Let s_1,s_2,s_3,...,s_m be the greedy partition of n into squares (n = s_1+s_2+s_3+...+s_m) such that s_1 >= s_2 >= s_3 >= ... >= s_m then a(n) = 0*s_1 + 1*s_2 + 2*s_3 + ... + (m-1)*s_m.
This sequence contains only numbers which can be written in the form c_1^2 + 2*c_2^2 + ... + m*c_m^2 with c_1 >= c_2 >= c_m. This excludes 2,5,7,8,... .

Examples

			a(41): 41 - 6^2 = 5; 5 - 2^2 = 1; 1 - 1^2 = 0 -> 5+1 = 6 = a(41).
		

Crossrefs

Programs

  • Mathematica
    Table[Total[Rest[NestWhileList[#-Floor[Sqrt[#]]^2&,n,#>0&]]],{n,0,90}] (* Harvey P. Dale, Apr 27 2025 *)
  • PARI
    A350178(n)={my(r=0); while(n-=sqrtint(n)^2, r+=n); r};

Formula

a(n) = n - r^2 + a(n - r^2) = a(n - r^2 + (b + r)^2) = a(n + b^2 + 2*b*r), r = floor(sqrt(n)), for any b >= 0. True because a(n) depends only on the distance to the next square <= n.
a(n) = Sum_{k>0} A053186^k(n).
Previous Showing 31-40 of 46 results. Next