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.

A008685 Lengths of months in the Gregorian calendar.

Original entry on oeis.org

31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31
Offset: 1

Views

Author

Keywords

Comments

To make the definition unambiguous, consider these as starting from January 2001 (or, equivalently, AD 1 in the proleptic Gregorian calendar). [Charles R Greathouse IV, Sep 28 2011]

Crossrefs

Cf. A061251.

Programs

  • Haskell
    a008685 n = a008685_list !! (n-1)
    a008685_list = concatMap t [1..] where
       t y = [31, 28 + leap, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
             where leap = if mod y 4 == 0 &&
                             (mod y 100 > 0 || mod y 400 == 0) then 1 else 0
    -- Reinhard Zumkeller, Jun 19 2015
    
  • Mathematica
    year1 = 2001; year2 = 2100;
    PreviousDate[#, "Day"][[1, 3]]& /@ Flatten[Table[{#, m, 1}, {m, Append[ Range[2, 12], 1]}]& /@ Range[year1, year2], 1] (* Jean-François Alcover, Aug 01 2018 *)
  • PARI
    v=[];for(n=1,50,v=concat(v,[31, if(n%4||(n%100==0&&n%400),28,29), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]));v
    
  • Python
    def a(n):
        y, m = 1 + (n-1)//12, (n-1)%12
        leap = int((y%4 == 0 and y%100 != 0) or y%400 == 0)
        return [31, 28+leap, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][m]
    print([a(n) for n in range(1, 64)]) # Michael S. Branicky, Feb 04 2024

Formula

a(n) = a(n-4800). [Charles R Greathouse IV, Sep 28 2011]