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 11-14 of 14 results.

A288797 Square array a(p,q) = p^2 + q^2 - 2*p - 2*q + 2*gcd(p,q), p >= 1, q >= 1, read by antidiagonals.

Original entry on oeis.org

0, 1, 1, 4, 4, 4, 9, 5, 5, 9, 16, 12, 12, 12, 16, 25, 17, 13, 13, 17, 25, 36, 28, 20, 24, 20, 28, 36, 49, 37, 33, 25, 25, 33, 37, 49, 64, 52, 40, 36, 40, 36, 40, 52, 64, 81, 65, 53, 45, 41, 41, 45, 53, 65, 81, 100, 84, 72, 64, 52, 60, 52, 64, 72, 84, 100
Offset: 1

Views

Author

Luc Rousseau, Jun 16 2017

Keywords

Comments

In the Cartesian plane, let r(p,q) denote the rotation with center origin and angle associated to slope p/q (p: number of units upwards, q: number of units towards the right).
Let R(p,q) be the square of area p^2 + q^2 = R^2, with vertices (0,0), (0,R), (R,R), (R,0).
The natural unit squares (i.e., the (a,a+1) X (b,b+1) Cartesian products, with a and b integers) are transformed by r(p,q) into rotated unit squares.
a(p,q) is the number of rotated unit squares that fully land inside R(p,q).

Examples

			Table begins:
    0   1   4   9  16  25 ...
    1   4   5  12  17  28 ...
    4   5  12  13  20  33 ...
    9  12  13  24  25  36 ...
   16  17  20  25  40  41 ...
   25  28  33  36  41  60 ...
  ... ... ... ... ... ... ...
		

Crossrefs

Programs

  • Mathematica
    A[p_, q_] := p^2 + q^2 - 2*p - 2*q + 2*GCD[p, q];
    (* or, checking without the formula: *)
    okQ[{a_, b_}, p_, q_] := Module[{r2 = p^2 + q^2}, 0 <= a*q - b*p <= r2 && 0 <= a*p + b*q <= r2 && 0 <= a*q - b*p + q <= r2 && 0 <= a*p + b*q + p <= r2 && 0 <= a*q - (b + 1)*p <= r2 && 0 <= a*p + b*q + q <= r2 && 0 <= (a + 1)*q - (b + 1)*p <= r2 && 0 <= a*p + b*q + p + q <= r2];
    A[p_, q_] := Module[{r}, r = Reduce[okQ[{a, b}, p, q], {a, b}, Integers]; If[r[[0]] === And, 1, Length[r]]];
    Flatten[Table[A[p - q + 1, q], {p, 1, 11}, {q, 1, p}]] (* Jean-François Alcover, Jun 17 2017 *)
  • PARI
    a(p,q)=p^2+q^2-2*p-2*q+2*gcd(p,q)
    for(n=2,12,for(p=1,n-1,{q=n-p;print(a(p,q))}))

Formula

a(p,q) = p^2 + q^2 - 2*p - 2*q + 2*gcd(p,q).
a(p,1) = a(1,p) = (p-1)^2 = A000290(p-1).
a(p,p) = 2*p*(p-1) = 4*A000217(p-1).
a(p,p+1) = 2*p*(p-1)+1 = A001844(p-1).
a(p,p+2) = 2*p^2+2*gcd(2,p) = 2*p^2+3+(-1)^(p) = 4*A099392(p-1) = 4*A080827(p).
a(p,p+3) = 2*p^2+2*p+5+4*A079978(p) = 1+4*(1+A143101(p)).
a(p,2*p) = p*(5*p-4) = A051624(p).
a(p,3*p) = 2*p*(5*p-3) = 4*A000566(p).

A328005 Number of distinct coefficients in functional composition of 1 + x + ... + x^(n-1) with itself.

Original entry on oeis.org

0, 1, 2, 4, 8, 13, 19, 25, 33, 41, 51, 61, 73, 85, 99, 113, 129, 145, 163, 181, 201, 221, 243, 265, 289, 313, 339, 365, 393, 421, 451, 481, 513, 545, 579, 613, 649, 685, 723, 761, 801, 841, 883, 925, 969, 1013, 1059, 1105, 1153, 1201, 1251, 1301, 1353, 1405, 1459
Offset: 0

Views

Author

Vladimir Reshetnikov, Oct 01 2019

Keywords

Comments

Sum_{i=0..n-1} x^i = (x^n - 1)/(x - 1).

Examples

			For n = 4, the composition of 1 + x + x^2 + x^3 with itself is 1 + (1 + x + x^2 + x^3) + (1 + x + x^2 + x^3)^2 + (1 + x + x^2 + x^3)^3 = 4 + 6 x + 10 x^2 + 15 x^3 + 15 x^4 + 14 x^5 + 11 x^6 + 6 x^7 + 3 x^8 + x^9 that has 8 distinct coefficients [1, 3, 4, 6, 10, 11, 14, 15], so a(4) = 8.
The first few polynomials p_n(x) are 0, 1, x + 2, x^4 + 2*x^3 + 4*x^2 + 3*x + 3, ... with p_n(1) = A023037(n), n >= 0.
		

Crossrefs

Programs

  • Maple
    f:= n-> unapply(add(x^j, j=0..n-1), x):
    a:= n-> nops({coeffs(expand((f(n)@@2)(x)))} minus {0}):
    seq(a(n), n=0..60);  # Alois P. Heinz, Oct 01 2019
  • Mathematica
    Table[With[{s = Sum[x^k, {k, 0, n - 1}]}, Length[Union[CoefficientList[Expand[s /. x -> s], x]]]], {n, 0, 53}]
  • PARI
    a(n)={my(p=(1-x^n)/(1-x)); #Set(Vec(subst(p,x,p)))} \\ Andrew Howroyd, Oct 01 2019
    
  • SageMath
    def A328005(n):
        R. = PolynomialRing(ZZ)
        q = R(sum(x^k for k in range(n)))
        return len(Set(q.substitute(x=q).list()))
    print([A328005(n) for n in range(55)]) # Peter Luschny, Oct 02 2019

Formula

It appears that a(n) = (2*n^2 + (-1)^n + 3)/4 for n >= 5.
Conjectured g.f.: (x^7 - x^6 - x^5 + 2*x^3 + 1)*x/((x + 1)*(1 - x)^3).

A385821 Numbers k such that ceiling((k^2 + 1)/2) is prime.

Original entry on oeis.org

2, 3, 5, 6, 9, 11, 12, 15, 18, 19, 25, 29, 35, 39, 42, 45, 48, 49, 51, 54, 59, 60, 61, 65, 66, 69, 71, 72, 79, 84, 85, 90, 95, 101, 121, 131, 132, 139, 141, 144, 145, 150, 159, 165, 169, 171, 174, 175, 181, 186, 192, 195, 198, 199, 201, 204, 205, 209, 210, 219, 221, 231, 245, 246
Offset: 1

Views

Author

Emirhan Üçok, Jul 09 2025

Keywords

Examples

			5 is a term since ceiling((5^2 + 1)/2) = 13, which is prime.
8 is not a term since ceiling((8^2 + 1)/2) = 33, which is not prime.
		

Crossrefs

Positions of primes in A080827.

Programs

  • Mathematica
    Select[Range[246],PrimeQ[Ceiling[(#^2+1)/2]]&] (* James C. McMahon, Jul 15 2025 *)
  • PARI
    isok(k) = isprime(ceil((k^2+1)/2)); \\ Michel Marcus, Jul 10 2025
  • Python
    from sympy import isprime
    def ok(k): return isprime((k*k + 2) // 2)
    print([k for k in range(1, 247) if ok(k)])
    

A385406 Triangle read by rows: T(n, k) = n*(n+1)/2 - floor((n-1)/2) - (-1)^k * floor(k/2).

Original entry on oeis.org

1, 3, 2, 5, 4, 6, 9, 8, 10, 7, 13, 12, 14, 11, 15, 19, 18, 20, 17, 21, 16, 25, 24, 26, 23, 27, 22, 28, 33, 32, 34, 31, 35, 30, 36, 29, 41, 40, 42, 39, 43, 38, 44, 37, 45, 51, 50, 52, 49, 53, 48, 54, 47, 55, 46, 61, 60, 62, 59, 63, 58, 64, 57, 65, 56, 66, 73, 72, 74, 71, 75, 70, 76, 69, 77, 68, 78, 67
Offset: 1

Views

Author

Werner Schulte, Jun 27 2025

Keywords

Comments

This triangle seen as a sequence yields a permutation of the natural numbers (A000027).

Examples

			Triangle T(n, k) for 1 <= k <= n starts:
n \k :   1   2   3   4   5   6   7   8   9  10  11  12  13
==========================================================
   1 :   1
   2 :   3   2
   3 :   5   4   6
   4 :   9   8  10   7
   5 :  13  12  14  11  15
   6 :  19  18  20  17  21  16
   7 :  25  24  26  23  27  22  28
   8 :  33  32  34  31  35  30  36  29
   9 :  41  40  42  39  43  38  44  37  45
  10 :  51  50  52  49  53  48  54  47  55  46
  11 :  61  60  62  59  63  58  64  57  65  56  66
  12 :  73  72  74  71  75  70  76  69  77  68  78  67
  13 :  85  84  86  83  87  82  88  81  89  80  90  79  91
  etc.
		

Crossrefs

Cf. A080827 (column 1), A128918 (main diagonal), A006003 (row sums), A213399.

Programs

  • Mathematica
    T[n_, k_] := n*(n+1)/2 - Floor[(n-1)/2] - (-1)^k*Floor[k/2]; Table[T[n, k], {n, 1, 12}, {k, 1, n}] // Flatten (* Amiram Eldar, Jun 28 2025 *)
  • PARI
    T(n, k) = n*(n+1)/2 - floor((n-1)/2) - (-1)^k * floor(k/2)

Formula

T(n, k) = T(n, k-1) - (-1)^k * (k-1) for 1 < k <= n with initial values T(n, 1) = n*(n+1)/2 - floor((n-1)/2) for n >= 1.
T(n, n) = n*(n+1)/2 + (1-n) * (1 - n mod 2) = A128918(n).
T(2*n-1, n) = 2*n^2 - 2*n + 1 - (-1)^n * floor(n/2) = A213399(n-1).
Previous Showing 11-14 of 14 results.