New answers tagged

0 votes

What is the average of n, the closest prime to n, the square of n and the closest Fibonacci number to n?

Haskell, 150 bytes ...
user avatar
  • 421
1 vote

Gödel numbering of a string

Haskell, 95 bytes e=(product.zipWith(^)[p|p<-[2..],all((>0).mod p)[2..p-1]]<$>).mapM(`lookup`zip"0s~|A()"[1,3..]) Try it online!
user avatar
  • 421
1 vote

Goldbach partitions

Regex 🐇 (ECMAScriptRME / Perl / PCRE), 38 bytes ^(x+)(?!(.*(?=\1$))?((xx+)\4+$|x?$))\1 Try it on replit.com! - ECMAScript (...
user avatar
  • 9,360
1 vote

Can the number reach 1 by repeatedly subtracting the largest prime less than it?

05AB1E, 7 bytes ΔD<ÅPà- Outputs 2 as falsey (only 1 is truthy in 05AB1E). Try it online ...
user avatar
0 votes

Is it a semiprime?

cQuents, 5 bytes 2=Lq$ Try it online! 1 for truthy, 0 for falsey. Explanation ...
user avatar
  • 13.5k
0 votes

Is it a semiprime?

Alice, 15 bytes /O\cdtv @I/ nt< Try it online! Flattened ...
user avatar
  • 1,778
6 votes

The program that will find the next prime number

Regex 🐇 (PCRE2 v10.35 or later), 80 77 bytes ^(?=(?*(x+?)(x*$))(?!(?*(xx+)(x+$))(?=\3*(x+))(?=\4\5(x*))\6\2\3*$))\2x+|\B|$ ...
user avatar
  • 9,360
1 vote

Approximate Brun's Constant

Vyxal sḋ, 13 bytes ʁ~æ2l'÷ε2=;fĖ Try it online or verify all test cases. Explanation: ...
user avatar
0 votes

List of primes under a million

C (gcc), 59 bytes i;main(n){for(;n++<1e6;dprintf(i,"%d ",n))for(i=n;n%--i;);} dprintf(3) prints to file ...
user avatar
  • 500
1 vote

Prime counting function

C (clang), 49 bytes p(n,i){for(i=n;--i&&n%i;);return--n?p(n)+!--i:0;} Assumes n is positive. Try it online!
user avatar
  • 500
0 votes

Is it a super-prime?

C (clang), 92 bytes #define s for(i=e;--i&&e%i;p+=i<3) p,r,i;m(e){s;for(p=r=i==e%2;--e;)s;e=p+1;s;return 1<i<r;} Try it online!
user avatar
  • 500
1 vote

Prime counting function

Python 2, 55 bytes n=input() s=p=i=1 while i<n:p*=i*i;i+=1;s+=p%i print~-s Try it online! A programification of the below. The Python 3 equivalent is 62 bytes. ...
user avatar
  • 9,360
1 vote

Prime counting function

Vyxal l, 2 bytes ¡Ǐ Try it Online! - test cases only This is the same as the 3 byte answer below except the length is taken by ...
user avatar
  • 9,360
0 votes

Is it a super-prime?

05AB1E, 6 bytes .Ø>‚pß Try it online! - 05AB1E Try it online! - 05AB1E - test cases only Try it online! - 05AB1E (legacy) - test cases only Equal in length to ...
user avatar
  • 9,360
2 votes

Is it a super-prime?

Vyxal g, 4 bytes ¡†"æ Try it Online! - test cases only This is the same as the 5 byte answer below except the minimum is ...
user avatar
  • 9,360
1 vote

Calculate the prime factors

Regex (.NET), 31 bytes ((?=(xx+?)\2*$)(x+)\3*(?=\3$))* Takes its input in unary, as a string of x characters whose length ...
user avatar
  • 9,360

Top 50 recent answers are included