255 votes

Is this number a prime?

hello, world!, 13 hello, world!
user avatar
  • 21.9k
169 votes

Is this number a prime?

Hexagony, 29 bytes .?'.).@@/'/.!.>+=(<.!)}($>(<% The readable version of this code is: ...
user avatar
  • 3,341
135 votes

Calculate the number of primes up to n

C, 0.026119s (Mar 12 2016) ...
user avatar
  • 207k
128 votes

Is this even or odd?

ArnoldC, 299 283 bytes ...
user avatar
  • 100k
100 votes
Accepted

Find the Smoothest Number

CJam - 13 q~,>{mfW=}$0= Try it at http://cjam.aditsu.net/ Example input: 2001 2014 Example output: ...
user avatar
74 votes

Is this number a prime?

Hexagony, 218 92 58 55 bytes Notice: This answer has been solidly beaten with a side-length 4 solution by Etoplay. ...
user avatar
72 votes

Find the Smoothest Number

Regex (.NET PCRE flavour), 183 129 bytes Don't try this at home! This is not really a contender for the win. But Eric Tressler suggested solving this problem with nothing but a regex, and I couldn't ...
user avatar
70 votes

Is this number a prime?

Pyth, 4 bytes }QPQ Prints True or False.
user avatar
  • 38.8k
65 votes

Is this number a prime?

Retina, 16 bytes ^(?!(..+)\1+$).. Try it online! Let's start with a classic: detecting primes with a regex. Input should be given in unary, using any repeated ...
user avatar
65 votes

Coprimes up to N

Python 2, 61 47 bytes lambda n:[k/n for k in range(n*n)if k/n*k%n==1] Try it online! Background Consider the ring \$(Z_n, +_n, \cdot_n)\$. While this ring is ...
user avatar
  • 207k
51 votes

Is this number a prime?

CJam, 4 bytes qimp CJam has a built-in operator for primality testing.
user avatar
  • 42.8k
51 votes

Is this number a prime?

Hexagony, 28 bytes Since Etoplay absolutely trounced me on this question, I felt that I had to outgolf his only other answer. ...
user avatar
  • 11.4k
51 votes

Is this even or odd?

brainfuck, 8 bytes +[,>,]<. Input is in unary. Output is the 1 (truthy) for odd numbers and NUL (falsy) for even numbers. Try it online! How it works We ...
user avatar
  • 207k
49 votes

Is this number a prime?

Help, WarDoq!, 1 byte P Outputs 1 if the input is prime, 0 otherwise.
user avatar
  • 38.8k
49 votes

Compute the Carmichael function

Mathematica, 16 bytes CarmichaelLambda Well...
user avatar
48 votes
Accepted

Is it a Proth number?

Jelly, 5 bytes ’&C²> Try it online! or verify all test cases. Let \$\newcommand{\&}[]{\text{ & }}j\$ be a strictly positive integer. \$j + 1\$ ...
user avatar
  • 207k
48 votes

Is it a Proth number?

Python, 22 bytes lambda N:N-1&1-N>N**.5 This is a port of my Jelly answer. Test it on Ideone. How it works Let \$\newcommand{\&}[]{\text{ & }}j\$ ...
user avatar
  • 207k
46 votes

Calculate Phi (not Pi)

Regex (.NET), 122 113 bytes ^(?=((?=.*$(?<=^(\3+(.+.))(.*?(?>(.\4)?)))).)+(.*))((?=.*(?=\6$)(?<=(?!(.+.)\8*(?=\6$)(?<=^\8+))(.+?(?>\9?)))).)+ ...
user avatar
46 votes

Theoretically output Graham's number

Binary lambda calculus, 114 bits = 14.25 bytes Hexdump: 00000000: 4457 42b0 2d88 1f9d 740e 5ed0 39ce 80 DWB.-...t.^.9.. Binary: ...
user avatar
46 votes

Abandon all squares, ye who divide me

05AB1E, 2 bytes fP Try it online! How it works ...
user avatar
  • 207k
44 votes
Accepted

Well that's odd... no wait, that's even!

CJam, 18 17 13 bytes Thanks to aditsu for saving 4 bytes. qW:O%eu~"eo"= Try the test suite here. (The test suite is too long for the permalink. Just copy them ...
user avatar
40 votes

Theoretically output Graham's number

Haskell, 41 bytes i=((!!).).iterate i(($3).i(`i`1)(*3))4 64 Explanation: (`i`1)f n = ...
user avatar
40 votes

Is this even or odd?

Mathematica, 4 bytes OddQ Gives True for odd inputs and False for even inputs, who knew? ...
user avatar
39 votes
Accepted

Greatest Common Divisor

Retina, 16 ^(.+)\1* \1+$ $1 This doesn't use Euclid's algorithm at all - instead it finds the GCD using regex matching groups. Try it online. - This example ...
user avatar
38 votes

Is this number a prime?

Mornington Crescent, 2448 bytes We're back in London! ...
user avatar
38 votes

Is this number evil?

Z80 Assembly (8-bit), 2 bytes The following code only works with values up to 255: ...
user avatar
37 votes
Accepted

Sharing (characters) is Caring!

20 languages Using  ()-#*.05;=>^Vefikloqrst (24 characters) so far: ...
user avatar
  • 66.1k
34 votes

How many partitions do I have?

Mathematica, 11 bytes PartitionsP Explanation ¯\_(ツ)_/¯
user avatar
  • 4,650

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