an=2a(n-1)+n-1a(n-1)=2a(n-2)+n-2···*2a(n-2)=2a(n-3)+n-3···*2····a2=2a1+1···*2再全部相加。消项得an=2a1+n-1+2*(1+2+3+····+n-2)=(n²-n+4)/2