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-2 of 2 results.

A354330 Distance from the sum of the first n positive triangular numbers to the nearest triangular number.

Original entry on oeis.org

0, 0, 1, 0, 1, 1, 1, 6, 0, 6, 10, 10, 13, 10, 1, 14, 4, 21, 12, 4, 0, 1, 8, 22, 28, 1, 36, 1, 35, 30, 10, 4, 11, 10, 0, 20, 51, 41, 10, 71, 4, 62, 41, 6, 45, 75, 91, 88, 97, 85, 55, 10, 51, 100, 10, 99, 20, 124, 29, 56, 130, 90, 48, 20, 7, 10, 30, 68, 125, 136
Offset: 0

Views

Author

Paolo Xausa, Jun 04 2022

Keywords

Comments

a(n) = 0 for n in {0, 1, 3, 8, 20, 34} = A224421.

Examples

			a(4) = 1 because the sum of the first 4 positive triangular numbers is 1 + 3 + 6 + 10 = 20, the nearest triangular number is 21 and 21 - 20 = 1.
		

Crossrefs

Programs

  • Mathematica
    nterms=100;Table[ts=n(n+1)(n+2)/3;t=Floor[Sqrt[ts]];Abs[t^2+t-ts]/2,{n,0,nterms-1}]
  • PARI
    a(n)=my(ts=n*(n+1)*(n+2)/3,t=sqrtint(ts));abs(t^2+t-ts)/2;
    vector(100,n,a(n-1)) \\ Paolo Xausa, Jul 06 2022
    
  • Python
    from math import isqrt
    def A354330(n): return abs((m:=isqrt(k:=n*(n*(n + 3) + 2)//3))*(m+1)-k)>>1 # Chai Wah Wu, Jul 15 2022

Formula

a(n) = A053616(A000292(n)).
a(n) = abs(A000292(n) - A354329(n)).

A366094 Least prime nearest to the sum of the first n primes.

Original entry on oeis.org

2, 2, 5, 11, 17, 29, 41, 59, 79, 101, 127, 157, 197, 239, 281, 331, 379, 439, 499, 569, 641, 709, 787, 877, 967, 1061, 1163, 1259, 1373, 1481, 1597, 1721, 1847, 1987, 2129, 2273, 2423, 2579, 2749, 2917, 3089, 3271, 3449, 3637, 3833, 4027, 4229, 4441, 4663, 4889
Offset: 0

Views

Author

Paolo Xausa, Sep 29 2023

Keywords

Examples

			a(3) = 11 because the sum of the first 3 primes is 2 + 3 + 5 = 10 and the nearest prime is 11.
a(10) = 127 because the sum of the first 10 primes is 129, which is equidistant from the nearest primes (127 and 131), and 127 is the smaller one.
		

Crossrefs

Programs

  • Mathematica
    pNearest[n_]:=If[PrimeQ[n],n,With[{np=NextPrime[n],pp=NextPrime[n,-1]},If[np-nA366094list[nmax_]:=Prepend[Map[pNearest,Accumulate[Prime[Range[nmax]]]],2];
    A366094list[100]
  • Python
    from sympy import prime, nextprime, prevprime
    def A366094(n): return (p if ((m:=sum(prime(i) for i in range(1,n+1)))<<1)-(p:=prevprime(m+1))<=(k:=nextprime(m)) else k) if n else 2 # Chai Wah Wu, Oct 03 2023
Showing 1-2 of 2 results.