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 Answer

minor update
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

JavaScript (ES6), (削除) 66 (削除ここまで) 65 bytes

Returns the \$n\$-th term, 0-indexed.

Uses @Neil's trickmethod.

n=>(g=a=>i<2*n?g([s,...a.map(x=>s+=a[_=>s+=a[--j],j=i++)]):s>>n)([i=s=1])

Try it online! Try it online!

JavaScript (ES6), (削除) 66 (削除ここまで) 65 bytes

Returns the \$n\$-th term, 0-indexed.

Uses @Neil's trick.

n=>(g=a=>i<2*n?g([s,...a.map(x=>s+=a[--j],j=i++)]):s>>n)([i=s=1])

Try it online!

JavaScript (ES6), (削除) 66 (削除ここまで) 65 bytes

Returns the \$n\$-th term, 0-indexed.

Uses @Neil's method.

n=>(g=a=>i<2*n?g([s,...a.map(_=>s+=a[--j],j=i++)]):s>>n)([i=s=1])

Try it online!

saved 1 byte
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

JavaScript (ES6), 66(削除) 66 (削除ここまで) 65 bytes

Returns the \$n\$-th term, 0-indexed.

Uses @Neil's trick.

n=>(g=a=>i++<2*ng=a=>i<2*n?g([s,...a.reverse().map(x=>s+=xx=>s+=a[--j],j=i++)]):s>>n)([i=s=1])

Try it online! Try it online!

JavaScript (ES6), 66 bytes

Returns the \$n\$-th term, 0-indexed.

Uses @Neil's trick.

n=>(g=a=>i++<2*n?g([s,...a.reverse().map(x=>s+=x)]):s>>n)([i=s=1])

Try it online!

JavaScript (ES6), (削除) 66 (削除ここまで) 65 bytes

Returns the \$n\$-th term, 0-indexed.

Uses @Neil's trick.

n=>(g=a=>i<2*n?g([s,...a.map(x=>s+=a[--j],j=i++)]):s>>n)([i=s=1])

Try it online!

Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

JavaScript (ES6), 66 bytes

Returns the \$n\$-th term, 0-indexed.

Uses @Neil's trick.

n=>(g=a=>i++<2*n?g([s,...a.reverse().map(x=>s+=x)]):s>>n)([i=s=1])

Try it online!

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