Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Revisions

2 of 3
added 7 characters in body
Giuseppe
  • 29.4k
  • 3
  • 33
  • 106

R, 62 bytes

function(l)c(p<-Reduce(function(x,y)(x+y)/2,l),a<-mean(l),p-a)

Try it online!

Pretty straightforward implementation.

R, 51 bytes

function(l,L=sum(l|1))sum(l*2^(c(1,1:(L-1))-L)-l/L)

Try it online!

This approach is perhaps more amenable to an improvement that I have overlooked, but only returns the difference progressive - arithmetic.

Giuseppe
  • 29.4k
  • 3
  • 33
  • 106

AltStyle によって変換されたページ (->オリジナル) /