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.

A137442 n^2 followed by smallest integer not yet listed.

Original entry on oeis.org

1, 2, 4, 3, 9, 5, 16, 6, 25, 7, 36, 8, 49, 10, 64, 11, 81, 12, 100, 13, 121, 14, 144, 15, 169, 17, 196, 18, 225, 19, 256, 20, 289, 21, 324, 22, 361, 23, 400, 24, 441, 26, 484, 27, 529, 28, 576, 29, 625, 30, 676, 31, 729, 32, 784, 33, 841, 34, 900, 35, 961, 37, 1024, 38
Offset: 1

Views

Author

Andy Martin, Apr 18 2008

Keywords

Comments

Sequence is a permutation of the positive integers.

Crossrefs

Cf. A000463.

Programs

  • Mathematica
    f[s_List] := Block[{k = 1}, While[ MemberQ[s, k], k++ ]; Flatten@ Append[s, {((2 + Length@s)/2)^2, k}]]; Nest[f, {1, 2}, 33] (* Robert G. Wilson v, May 31 2009 *)
    Module[{nn=40,sq,int,len},sq=Range[nn]^2;int=Complement[Range[nn],sq];len=Min[Length[int],nn];Riffle[Take[sq,len],Take[int,len]]](* Harvey P. Dale, Nov 05 2013 *)
  • PARI
    lista(nn) = {for (n=1, nn, print1(n^2, ", ", n+round(sqrt(n)), ", "););} \\ Michel Marcus, Nov 02 2014
    
  • PARI
    a(n) = if (n % 2, ((n+1)/2)^2, (n/2)+round(sqrt(n/2))); \\ Michel Marcus, Nov 02 2014
  • Ruby
    # correct to any term:
    sk_ct = 2
    skip = 4
    at = 1
    (1..(1.0/0)).each{ |i|
    if (at+=1) == skip
    at+=1
    sk_ct +=1
    skip = sk_ct * sk_ct
    end
    print i*i, " ", at, " "
    }
    
  • Ruby
    # Simpler Ruby code, correct until i is so large that floating point rounding causes errors. I estimate this will be before i reaches 10000000000000000
    (1..(1.0/0)).each{ |i|
    print i*i, " ", i + (Math.sqrt(i) + 0.5).to_i, " "
    }
    

Formula

Formula, generating two terms for every m: m^2, m + round(sqrt(m)).
IFTE(n mod 2 ==1, ((n+1)/2)^2, (n/2)+round(sqrt(n/2),0)). - Gerald Hillier, Nov 15 2010

Extensions

More terms from Robert G. Wilson v, May 31 2009