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.

A360061 Lexicographically earliest increasing sequence such that a(1) = 2 and for n >= 2, a(1)^2 + a(2)^2 + ... + a(n)^2 is a prime.

Original entry on oeis.org

2, 3, 4, 12, 48, 54, 66, 138, 144, 162, 168, 180, 198, 234, 252, 264, 330, 360, 366, 372, 402, 420, 444, 462, 480, 534, 546, 552, 564, 576, 600, 630, 642, 678, 702, 744, 756, 846, 852, 858, 882, 966, 1008, 1206, 1242, 1254, 1266, 1272, 1296, 1302, 1338, 1650
Offset: 1

Views

Author

Win Wang, Jan 23 2023

Keywords

Examples

			For n >= 2, partial sums of squares are (showing primality): 2^2 + 3^2 = 13; 13 + 4^2 = 29; 29 + 12^2 = 173; 173 + 48^2 = 2477; ...
		

Crossrefs

Programs

  • Haskell
    import Math.NumberTheory.Primes.Testing (isPrime)
    a360061_list = 2 : 3 : recurse 4 13 where
      recurse n p
        | isPrime(n^2 + p) = n : recurse (n+1) (n^2 + p)
        | otherwise        = recurse (n+1) p
    -- Peter Kagey, Jan 25 2023
  • Maple
    s:= proc(n) option remember; `if`(n<1, 0, a(n)^2+s(n-1)) end:
    a:= proc(n) option remember; local k, m;
          k:= s(n-1); for m from 1+a(n-1)
          while not isprime(k+m^2) do od; m
        end: a(1):=2:
    seq(a(n), n=1..52);  # Alois P. Heinz, Jan 26 2023
  • Mathematica
    s[n_] := s[n] = If[n < 1, 0, a[n]^2 + s[n-1]];
    a[n_] := a[n] = Module[{k, m},
       k = s[n-1]; For[m = 1 + a[n-1],
       !PrimeQ[k + m^2], m++]; m];
    a[1] = 2;
    Table[a[n], {n, 1, 52}] (* Jean-François Alcover, Feb 03 2025, after Alois P. Heinz *)