11 votes

Calculate Pi unto a point using the Nilakantha series

Python 3.8 (pre-release), 38 bytes (@xnor) f=lambda n,i=.5:i//n/n or 2/i-f(n,i+1) Try it online! Python 3.8 (pre-release), 40 bytes (@xnor) ...
  • 9,318
7 votes
Accepted

The "Fly straight, dammit" sequence

05AB1E, 12 bytes 1‚λDN¿DiNOë÷ Outputs the infinite sequence. Try it online. Explanation: ...
7 votes

IMO Question Six with a difference

Python, 49 bytes f=lambda n,a=1:a>n+1or(n*n-2)%~(a*(a+n))*f(n,a+1) Try it online! Outputs Truthy/Falsey reversed. Checks whether $$\frac{n^2-2}{a(a+n)+1}$$ is ...
  • 139k
6 votes

Number of ways to make an amount with coins

JavaScript (ES6), 41 bytes Saved 3 bytes thanks to @ovs f=(n,k=10)=>n?k*n>0&&f(n,k>>1)+f(n-k,k):1 Try it online! 40 bytes Suggested by @tsh ...
  • 171k
6 votes

The "Fly straight, dammit" sequence

C (GCC), 65 bytes t,r;h(a,b){r=b?h(b,a%b):a;}c(n){n=n<2?:h(t=c(n-1),n)<2?t-~n:t/r;} Attempt This Online! This is based on py3programmer's answer; I'm posting ...
  • 22.6k
6 votes

Calculate Pi unto a point using the Nilakantha series

JavaScript (ES6), 32 bytes This version is based on @loopy-walt's answer, golfed by @xnor. f=(n,i=.5)=>i<n?2/i-f(n,i+1):1/n Try it online! JavaScript (ES6),...
  • 171k
6 votes
Accepted

Calculate Pi unto a point using the Nilakantha series

Jelly, 13 bytes RḤrƝP€4÷Ṛḅ-+3 A monadic Link that accepts a positive integer and yields the approximation (up to the floating point accuracy). Try it online! How? <...
6 votes

Count the number of compositions of \$n\$ in which the greatest part is odd

Python, 58 bytes f=lambda n,m=0:sum(f(k,max(m,n-k))for k in range(n))or m%2 Try it online! An exponential solution that implicitly generates all compositions by ...
  • 139k
5 votes

Sums of Consecutive Integers

K (ngn/k), 40 32 bytes {^/!'1+i@'*>-/i:&x=s-\:s:+\!1+x} Try it online! -8 bytes thanks to @ngn
  • 361
5 votes

Find the nth Mersenne Prime

JavaScript (ES6), 50 bytes Returns the \$n\$-th Mersenne prime, 1-indexed. n=>{for(k=1;n;n-=d<2)for(d=k-=~k;k%--d;);return k} Try it online! ...
  • 171k
5 votes

Calculate Pi unto a point using the Nilakantha series

Factor + koszul math.unicode,  68 64 bytes [ ""3 rot [0,b) [ -1^ 4 reach Π / * + [ 2 v+n ] dip ] each ] Attempt This ...
  • 11.5k
5 votes

Calculating Pi using the Gregory Leibniz series until n terms

05AB1E, 14 9 bytes L·<z··R®β -5 bytes porting @JonathanAllan's Jelly answer Try it online or verify all test cases. Original 14 bytes answer: ...
5 votes

Calculating Pi using the Gregory Leibniz series until n terms

Python 3, 36 35 bytes f=lambda n,k=1:n and 4/k-f(n-1,k+2) Try it online! -1 thanks to Mukundan314.
  • 7,661
5 votes

Count the number of compositions of \$n\$ in which the greatest part is odd

Python, 92 bytes g=[17*[1,-1]] r=range(33) for i in r:g+=[sum(y[~k:])for*y,k in zip(*g,r)],;print(sum(g[-1])) Attempt This Online! Prints 33 terms. How? First ...
  • 9,318
4 votes

Get the length of a Sumac Sequence

Ruby, 25 bytes f=->a,b{a>0?f[b,a-b]+1:0} Attempt This Online!
4 votes

Find the nth Mersenne Prime

Factor + math.primes.lucas-lehmer, 48 bytes [ 1 lfrom [ lucas-lehmer ] lfilter lnth 2^ 1 - ] Try it online! 0-indexed. ...
  • 11.5k
4 votes
Accepted

Find the nth Mersenne Prime

Vyxal G, 7 bytes Þ∞E‹~æẎ Try it Online! 7 bytes flagless (change to ...
  • 23.7k
4 votes

Number of ways to make an amount with coins

HOPS, 20 bytes mset(x+x^2+x^5+x^10) Attempt This Online!
  • 37.6k
4 votes
Accepted

Number of ways to make an amount with coins

Vyxal, 12 8 7 bytes Ṅ₀$ḊvΠ∑ Try it Online! 6 bytes with s flag Explained ...
  • 23.7k
4 votes

Number of ways to make an amount with coins

Wolfram Language (Mathematica), 36 bytes Length[{1,2,5,10}~FrobeniusSolve~#]& Try it online!
  • 23.3k
4 votes

Number of ways to make an amount with coins

Regex 🐇 (RME / Perl / PCRE / Raku:P5), 24 bytes ^x*(xx)*(x{5})*(x{10})*$ Takes its input ...
  • 10.2k
4 votes

The "Fly straight, dammit" sequence

Prolog (SWI), 68 56 bytes -12 bytes thanks to @Steffan N+X:-N>1,N-1+B,C=gcd(B,N),(C<2,X is B+N+1;X is B/C);X=1. Try it online!
  • 8,455
4 votes

Calculating Pi using the Gregory Leibniz series until n terms

C (gcc), 63 60 bytes float f(n){float m=4,p=1,d=1;for(;n--;d+=2,m=-m)p+=m/d;--p;} Try it online! Saved 3 bytes thanks to jdt!!!
  • 18.8k
4 votes
Accepted

Calculating Pi using the Gregory Leibniz series until n terms

Jelly, 8 bytes RḤ’4÷Ṛḅ- A monadic Link that accepts a positive integer, \$n\$, and yields a floating point number, \$\pi_n\$. Try it online! How? ...
4 votes

Count the number of compositions of \$n\$ in which the greatest part is odd

05AB1E, 15 11 bytes Åœ€œ€`Ù€àÉO -4 bytes outputting the \$n^{th}\$ value instead of mapping over the ranged list \$[1,33]\$ Outputs as a list. Very slow, and will ...
4 votes

Count the number of compositions of \$n\$ in which the greatest part is odd

x86-64 machine code, 27 bytes 31 C9 48 0F AB F9 6A 01 58 99 89 CF 41 F7 D2 8D 34 3F 21 F7 75 F7 29 D0 E2 EF C3 Try it online! Following the standard calling ...
  • 7,661
3 votes

All together now

Prolog (SWI), 40 bytes \[A|S]:-S=[];(S=[A|_];\+member(A,S)),\S. Try it online! -3 thanks to Jo King Similar to xnor's second Haskell answer. This won't work on TIO ...
  • 10.9k
3 votes

Product of Divisors

Vyxal, 2 bytes Explanation: K # Gets the divisors of a number Π # Product of array Try it Online!
  • 199
3 votes

One OEIS after another

398. GeoGebra, 176 bytes, A000498 ...
  • 8,455
3 votes

Sums of Consecutive Integers

K (ngn/k), 61 41 bytes h:{i{x':y}\:i:1+!x} f:{i@*|&x=+/'i:,/h@x} Try it online! ¯20 bytes thanks to @doug
  • 1,654

Only top scored, non community-wiki answers of a minimum length are eligible