# Tag Info

## Hot answers tagged sequence

### 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
Accepted

### The "Fly straight, dammit" sequence

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

### 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

### 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

### 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

### 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
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? <...
• 93.9k

### 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

### 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

### 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

### 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

### 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: ...
• 109k

### 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

### 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

### Get the length of a Sumac Sequence

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

### 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
Accepted

### Find the nth Mersenne Prime

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

### 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
Accepted

• 10.2k

### 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

### 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
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? ...
• 93.9k

### 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 ...
• 109k

### 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

### 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

### Product of Divisors

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