A242667 Number of ways of representing n as the sum of one or more consecutive squarefree numbers.
1, 1, 2, 0, 2, 2, 1, 1, 0, 2, 3, 0, 2, 2, 1, 1, 3, 1, 1, 0, 3, 1, 3, 2, 0, 1, 1, 2, 2, 1, 2, 1, 2, 4, 1, 1, 1, 2, 2, 1, 2, 3, 2, 1, 2, 2, 2, 1, 1, 0, 2, 1, 2, 0, 4, 0, 3, 2, 3, 0, 3, 2, 1, 1, 2, 3, 2, 0, 3, 3, 3, 3, 1, 1, 1, 1, 2, 3, 2, 2
Offset: 1
Keywords
Examples
a(6)=2 because n=6 itself is already a squarefree number (sum of 1 term), and 6 can in addition be written as A005117(1)+ A005117(2)+A005117(3), a sum of 3 consecutive squarefree numbers.
Links
- Robert Israel, Table of n, a(n) for n = 1..10000
Crossrefs
Cf. A005117.
Programs
-
Maple
A242667 := proc(n) a := 0 ; for i from 1 do if A005117(i) > n then return a; end if; for k from i do su := add(A005117(s),s=i..k) ; if su = n then a := a+1 ; elif su > n then break; fi ; end do: end do: end proc: seq(A242667(n),n=1..80) ; # R. J. Mathar, Jun 12 2014 # Alternative: N:= 1000:# to get the first N entries A005117:= select(numtheory:-issqrfree,[$1..N]): M:= nops(A005117); A:= Array(1..N): t0:= 0: for n from 1 to M-1 do t0:= t0 + A005117[n]; t:= t0; for i from 1 while t <= N do A[t] := A[t]+1; if n+i > M then break fi; t:= t + A005117[n+i]-A005117[i]; od; od: seq(A[i],i=1..N); # Robert Israel, Jun 25 2014
-
Mathematica
With[{N = 100}, (* to get the first N entries *) A005117 = Select[Range[N], SquareFreeQ]; M = Length[A005117]; A = Table[0, {N}]; t0 = 0; For[n = 1, n <= M-1, n++, t0 = t0+A005117[[n]]; t = t0; For[i = 1, t <= N, i++, A[[t]] = A[[t]]+1; If[n+i > M, Break[]]; t = t + A005117[[n+i]] - A005117[[i]]] ] ]; A (* Jean-François Alcover, Feb 07 2023, after Robert Israel *)
Comments