OFFSET
1,2
COMMENTS
Every positive integer is either of the form a(n)+n-1 or of the form a(n+1)-a(n)+n, but not both.
The sequence a(n)+n-1 is A109512. - Robert Price, Apr 16 2013
The sequence a(n+1)-a(n)+n is A224731. - Robert Price, Apr 16 2013
a(n) is the position of the first occurrence of n in A001462, i.e., A001462(a(n)) = n and A001462(m) < n for m < a(n). - Reinhard Zumkeller, Feb 09 2012 [Explanation added and first inequality corrected from A001462(m) < m by Glen Whitney, Oct 06 2015]
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
EXAMPLE
3 elements of {a(1),...,a(4)} are <= 4, so a(5) = a(4) + 3 = 9.
MAPLE
a[1]:= 1; m:= 0;
for n from 2 to 100 do
if a[m+1] <= n-1 then m:= m+1 fi;
a[n]:= a[n-1]+m;
od:
seq(a[i], i=1..100); # Robert Israel, Oct 07 2015
MATHEMATICA
a[1]=1; a[n_]:=a[n]=a[n-1]+Length[Select[a/@Range[n-1], #<n&]]
PROG
(PARI) a(n) = sum(k=1, n-1, t(k)) + 1;
t(n)=local(A, t, i); if(n<3, max(0, n), A=vector(n); t=A[i=2]=2; for(k=3, n, A[k]=A[k-1]+if(t--==0, t=A[i++ ]; 1)); A[n]);
vector(100, n, a(n)) \\ Altug Alkan, Oct 06 2015
(Haskell)
a095114 n = a095114_list !! (n-1)
a095114_list = 1 : f [1] 1 where
f xs@(x:_) k = y : f (y:xs) (k+1) where
y = x + length [z | z <- xs, z <= k]
-- Reinhard Zumkeller, Feb 09 2012
CROSSREFS
KEYWORD
nonn
AUTHOR
Dean Hickerson, following a suggestion of Leroy Quet, May 28 2004
STATUS
approved