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.

A186336 Number of ways of representing n as the sum of one or more consecutive semiprimes.

Original entry on oeis.org

0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 2, 0, 0, 0, 1, 2, 0, 0, 0, 2, 0, 1, 1, 0, 1, 2, 1, 0, 0, 2, 0, 0, 0, 2, 1, 1, 1, 0, 1, 3, 0, 0, 0, 2, 0, 0, 1, 1, 1, 1, 1, 2, 0, 0, 1, 1, 0, 1, 3, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 3, 0, 0, 1, 2, 1, 1, 0, 2, 0, 1, 0, 0, 2, 1, 1, 2, 1, 1, 0, 0, 0, 2, 0, 2, 2, 2, 0, 2, 0, 0, 1, 1, 1, 0, 0, 0, 3, 2, 0, 1, 0, 1, 2, 0, 0, 2, 1, 0, 2, 1, 1
Offset: 0

Views

Author

Alois P. Heinz, Feb 18 2011

Keywords

Examples

			a(4)  = 1:  4 = A001358(1) is the first semiprime.
a(10) = 2: 10 = A001358(1)+A001358(2) = 4+6 = A001358(4) = 10.
a(39) = 3: 39 = 6+9+10+14 = 10+14+15 = 39.
		

Crossrefs

Programs

  • Haskell
    a186336 n = f $ takeWhile (<= n) a001358_list where
       f []       = 0
       f (sp:sps) = g sp sps + f sps
       g spSum []                    = fromEnum (spSum == n)
       g spSum (sp:sps) | spSum < n  = g (sp + spSum) sps
                        | spSum == n = 1
                        | otherwise  = 0
    -- Reinhard Zumkeller, Feb 28 2011
  • Maple
    b:= proc(n) option remember; local k;
          if n=0 then 0
        else for k from b(n-1)+1
               while isprime(k) or 2<>add(i[2], i=ifactors(k)[2])
             do od; k
          fi
        end:
    pis:= proc(n) option remember; local k;
            if n<4 then 0
          elif n=4 then 1
          else k:= pis(n-1);
               k +`if`(b(k+1)=n, 1 ,0)
            fi
          end:
    ssp:= proc(i,j) option remember;
            b(j) + `if`(i=j, 0, ssp(i, j-1))
          end:
    a:= proc(n) option remember; local i, j, cnt, s;
          cnt:= 0;
          j:= pis(n);
          i:= j;
          while i>0 do
            s:= ssp(i,j);
            if sn then j:= j-1
          else cnt:= cnt+1;
               i, j:= i-1, j-1
            fi
          od; cnt
        end:
    seq(a(n), n=0..200);
  • Mathematica
    nmax = 120;
    sp = Select[Range[nmax], PrimeOmega[#] == 2&];
    lsp = Length[sp]; Clear[a]; a[_] = 0;
    Do[n = Total[sp[[i ;; j]]]; a[n] = a[n]+1, {i, 1, lsp}, {j, i, lsp}];
    Table[a[n], {n, 0, nmax}] (* Jean-François Alcover, Mar 13 2019 *)