You've recently made an account on a dodgy gambling site, where for a fee of 25 dollars, they will pay you back a random amount between 0 and 50 dollars. After getting around 5 dollars twice, you decide to prove the site is a scam. After accessing their external firewall with the default password, you find your way onto their database server, and find where the values for the minimum and maximum amounts are held. You decide to plug 25 '9's in as the maximum value, but get an error message saying the maximum value must be of type 'uint64'. However it is now that you notice some number keys don't seem to type into the remote console correctly. The challenge appears before you almost as if typed up on a Q+A site.

using only the conveniently installed programs for testing and executing your particular language, output the maximum size of an unsigned 64-bit integer value, however almost everything except the programming tools are broken on this machine, leaving you without the use of the numbers 1,2,4,6,8 - in either source code or literals, you also notice that it seems to take an exponentially longer amount of time to execute the program for each additional piece of code, so you'd better keep it short if you want to get rich before the drawing!

The Challenge

  • Write a program which outputs 18446744073709551615, the maximum value of an unsigned 64-bit integer, as either a number, or a single string.

  • Your source code cannot contain any of the characters '1','2','4','6' or '8'

  • if your language does not have an unsigned 64-bit integer or equivalent, the output can be in string format or otherwise, but must be the above number.

  • this is so shortest code in each language wins!

  • 14
    \$\begingroup\$ predefined values. pfft \$\endgroup\$ – Matthew Roh Feb 21 '17 at 12:29
  • \$\begingroup\$ can output be a hexadecimal number? \$\endgroup\$ – user902383 Feb 21 '17 at 13:25
  • 1
    \$\begingroup\$ @user902383 must be in the exact format, feel free to parse it as a hex number, as long as the output is in normal decimal notation. \$\endgroup\$ – colsw Feb 21 '17 at 14:16
  • 11
    \$\begingroup\$ I love the story lol. More challenges need a backstory like this \$\endgroup\$ – Cruncher Feb 22 '17 at 14:40
  • 4
    \$\begingroup\$ So now that there are many solutions to choose from, was the gambling site a fraud? \$\endgroup\$ – Tominator Feb 23 '17 at 10:32

78 Answers 78


Beeswax, 3 bytes



_   # Create a bee going horizontally across the line, reading the code
 M  # Decrement the bee's counter, which starts at 0.
    # This will set the counter to 2^64-1, because as bees don't have a concept of
    # negative numbers, all values that are negative are translated to 2^64-n,
    # and in this case, n = -1, as we are calculating 0 - 1.
  { # Print the value

Try it online!

This language is perfect for this challenge.

Here is an extract from the Esolang page on Beeswax:

As everyone knows, bees don’t have a concept of negative numbers, but they discovered that they can use the most significant bit of an address to get around that. Thus, coordinates relative to a bee’s position are realized by the two’s complements of the coordinates. This way, half of the 64-bit address space is available for local addressing without wraparound in each direction.

The maximum positive 64-bit two’s complement address is 9223372036854775807 or 0x7fffffffffffffff in 64 bit hex. All values from 0 up to this value translate identically to the same 64 bit value. All values n in the opposite (negative) direction translate to 2^64-n. For example: n=-1 is addressed by 18446744073709551615. n=-9223372036854775808 is addressed by 9223372036854775808.

This is basically unsigned longs.

EDIT: I'm still expecting Dennis to outgolf me with a 2-byte solution.

  • \$\begingroup\$ You don't need to print it if the form will return the value. See other answers. \$\endgroup\$ – MatthewRock Mar 24 '17 at 14:28

C, 26 bytes


Prints a unsigned long value.

Requires the size of long to be 64 bits.

  • \$\begingroup\$ Nice one. Pretty much the same in Perl: print~0. \$\endgroup\$ – Dada Feb 21 '17 at 11:42
  • 2
    \$\begingroup\$ ~0l should work. \$\endgroup\$ – Christoph Feb 21 '17 at 12:51
  • 12
    \$\begingroup\$ @AnixPasBesoin it's a lowercase 'L' :) \$\endgroup\$ – Quentin Feb 22 '17 at 11:03
  • 2
    \$\begingroup\$ You're assuming sizeof(long) * CHAR_BIT == 64. A reasonable assumption for golf, but worth pointing out. \$\endgroup\$ – Ray Feb 23 '17 at 3:11
  • 1
    \$\begingroup\$ @Chris it's the bitwise not operator. \$\endgroup\$ – Ven Feb 23 '17 at 15:45

64-bit SBCL Common Lisp, 18 bytes


Most positive word on 64-bit compiler is 64uint. It's something.

  • 7
    \$\begingroup\$ Best syntax :)) \$\endgroup\$ – seshoumara Feb 21 '17 at 14:58
  • 2
    \$\begingroup\$ Makes me very happy \$\endgroup\$ – Stan Strum Sep 12 '17 at 20:42

CJam (4 bytes)


Online demo

This calculates 1616 - 1 using builtin G for 16 and the decrement operator (.

  • 19
    \$\begingroup\$ Definitely GG! ;) \$\endgroup\$ – WasteD Feb 21 '17 at 13:31
  • \$\begingroup\$ gg, Peter, gg.. \$\endgroup\$ – cascading-style Feb 23 '17 at 2:20

Python3 REPL, 12 bytes

In REPL: ~-(~-3<<9*7)

Outside of REPL: print~-(~-3<<9*7) <--> Python2!

Here's another one at 17 bytes: ~-(~-3<<ord("?")).


Nothing super fancy. Here's it broken down:

~-           | Subtract 1 from the next value.
  (          | 
   ~-3       | Subtract 1 from 3, resulting in 2
      <<     | Binary shift 2's digits to left,
        9*7  | by 9*7 (63).
           ) | The value inside the parentheses is now 2**64.

The resulting expression is roughly (but not quite) ~-(2<<63) -> (2**64)-1. I use the tadpole operator twice here. A golfing tip about it is here.

There is also sys.maxint in Python2 which can be used, but I won't be looking at that.

repl.it <- testing link.

  • \$\begingroup\$ Why does this code look like a cat that ate another cat? \$\endgroup\$ – OldBunny2800 Feb 27 '17 at 20:19
  • \$\begingroup\$ @OldBunny2800 Is the ~-(~ part the eyes of the first cat? I can't see the second cat well... \$\endgroup\$ – Yytsi Sep 15 '17 at 10:29

bc, 15 13 bytes

Saved 2 bytes thanks to manatwork.


Nothing fancy, just (16^16)-1.

  • 2
    \$\begingroup\$ Welcome to PPCG! \$\endgroup\$ – ETHproductions Feb 21 '17 at 15:37
  • 1
    \$\begingroup\$ (a=9+7)^a-3/3 \$\endgroup\$ – manatwork Feb 23 '17 at 8:34
  • \$\begingroup\$ Thanks I was originally doing something like that in bash before I realised my answer was better as pure bc. \$\endgroup\$ – Richard Feb 23 '17 at 9:50

dc, 7 bytes

I think it's allowed for stack based languages to leave the answer on the top cell of the stack, similar to a return value for functions. If explicit printing is needed, add p at the end of the code.


Try it online!

It computes (2 64 - 1) using several tricks:

  • 2 is given as the number of digits (Z) found in integer 10 (A)
  • 64 is given as 5E. By default dc uses 10 as the input radix. Even so, it can accept numbers in hexadecimal notation, but they will be converted differently than you'd expect. Example: (5E)default = (5E)(input radix = 10) = (5 * 10 1) + (14(E) * 10 0) = 50 + 14 = 64

  • 1 is given as the stack's depth (z), since only (2 64) was present then

Alternative story:

However it is now that you notice some number keys don't seem to type into the remote console correctly. You take a deep breath and start testing each numerical key. It is worse than you thought! Not a single one works, and you're left with the task to produce your desired integer by using only letters and symbols.

Solution in dc: computing (16 16 - 1), still 7 bytes!

Fz+d^z-          # push 15, push 1, add, duplicate, exponentiate, push 1, subtract

Try it online!

  • 2
    \$\begingroup\$ Great alternative story \$\endgroup\$ – cascading-style Feb 23 '17 at 2:22

05AB1E, 4 bytes



žJ   # Push 4294967296
  n  # Squared
   < # Decreased by one

Finally! A chance to use 05AB1E's builtins for powers of two!

Try it online!

Another 4 byte answer:



  o  # 2 to the power of
žx   # 64
   < # Decreased by one

Try it online!

(if anyone is wondering, this question is older than all the other 4-byte answers)

  • \$\begingroup\$ I feel like there's a shorter solution along the lines of 64o< but I haven't found it yet. Something like '@Ço< with a creative 64 push... If you manage to push 64 with 1 byte, you can get 3 is the point I'm trying to make. \$\endgroup\$ – Magic Octopus Urn Feb 23 '17 at 19:51

Jelly, 4 bytes


Try it online!


⁴     # 16
 *    # exponentiate
  `   # last link as a monad, repeating the argument
   ’  # decrement

MATLAB / Octave, 5 bytes

@Sanchises posted an excellent MATLAB answer, however this one is a considerably different approach, so I'll post it anyway:


In MATLAB, tic returns the number of milliseconds past since the program was opened. Crucially the value it returns is a uint64 type. This gets away from having to cast a number to uint64 from MATLABs default type of double.

Any number divided by 0 in MATLAB is considered as infinity which for non-floating point types, MATLAB represents this as the maximum integer value for that type.

This also works with Octave though depending on which interpreter you use it may spit out a "division by zero" warning as well. You can try the code online here though as I say you get a /0 warning that doesn't appear in MATLAB.

  • \$\begingroup\$ Really clever approach, nice one. \$\endgroup\$ – colsw Feb 26 '17 at 15:37
  • \$\begingroup\$ I'm only seeing this answer now. Very clever! (of course, it does not work if you execute this on a very fast computer such that tic==0 at startup 😉) \$\endgroup\$ – Sanchises Jul 23 '18 at 7:32

Java (JDK), 28 bytes


Try it online!

  • \$\begingroup\$ Missing java "boilerplate" and system.out.print part \$\endgroup\$ – Viktor Mellgren Feb 21 '17 at 14:08
  • 2
    \$\begingroup\$ @ViktorMellgren This declares a lambda expression, which is perfectly fine. \$\endgroup\$ – Sanchises Feb 21 '17 at 14:30
  • \$\begingroup\$ This requires Java 8 \$\endgroup\$ – mbomb007 Feb 21 '17 at 14:43
  • 21
    \$\begingroup\$ Yes java 8 and up, no more boilerplate! Fear codegolfers! Java is a real contester now. This is the time you all were so scared about, all your codegolfing language are for nothing! Oh wait still 30 bytes,... hides \$\endgroup\$ – dwana Feb 21 '17 at 15:00
  • 5
    \$\begingroup\$ Surely the "shorter solution" uses the illegal characters 1846. \$\endgroup\$ – Neil Feb 21 '17 at 22:40

bc, 18, 16 bytes

  • Saved 2 bytes, thx @MrScapegrace
  • 1
    \$\begingroup\$ can you use something like -3/3 to get -1? \$\endgroup\$ – Mr Scapegrace Feb 21 '17 at 15:32
  • \$\begingroup\$ @MrScapegrace, yep that's a nice idea, thank you ! \$\endgroup\$ – zeppelin Feb 21 '17 at 15:34
  • \$\begingroup\$ @boboquack 55+9 = 64, not 63! \$\endgroup\$ – Jake Lee Feb 22 '17 at 10:54

PHP, 16 bytes

This is much like the answer from Ven: https://codegolf.stackexchange.com/a/110751/38505



For this to work, you need to be in a 64-bit architecture. This is because ~0 is -1, which is 111111111111111111111111111111111111111111111111111111111111‌​1111 in binary, in 64 bits, compared to 11111111111111111111111111111111 in 32-bits, and the numbers are plataform-dependent - Ismael Miguel

  • 1
    \$\begingroup\$ Lol. This works in bash too: printf %u $[~0]. \$\endgroup\$ – manatwork Feb 21 '17 at 14:55
  • \$\begingroup\$ Aha, nice @manatwork \$\endgroup\$ – ʰᵈˑ Feb 21 '17 at 14:58
  • \$\begingroup\$ This is architecture-dependent, it doesn't work on i386. \$\endgroup\$ – pts Feb 23 '17 at 13:54
  • 1
    \$\begingroup\$ @pts Obviously! i386 is 16/32-bits. PHP is very picky about that. For this to work, you need to be in a 64-bit architecture. This is because ~0 is -1, which is 1111111111111111111111111111111111111111111111111111111111111111 in binary, in 64 bits, compared to 11111111111111111111111111111111 in 32-bits, and the numbers are plataform-dependent. \$\endgroup\$ – Ismael Miguel Feb 23 '17 at 14:36
  • \$\begingroup\$ @ʰᵈˑYou're welcome. I must admit that I slacked a bit. I've copy-pasted 32 1's. If you want, you can fix your grammar a bit on your answer. \$\endgroup\$ – Ismael Miguel Feb 23 '17 at 14:42

MATLAB / Octave, 22 bytes

eye(['~rw}?='-9 ''])/0

Try it online!

eye is used to create a unit matrix (matrix with 1 on the diagonal, zero otherwise). Without arguments, this creates a 1x1 unit matrix, or in other words, just a 1. It takes an optional argument, which is the data type ('class' in MATLAB terminology) of the created matrix. We thus ask for a 1 of class uint64 , and divide it by zero which results in Inf in MATLAB, which gets clipped at intmax('uint64').

The vector ['~rw}?='-9 ''] evaluates to 'uint64'. Concatenating an empty char to a vector is 1 byte shorter than using char('~rw}?='-9).

Reasoning towards this answer: the built-in intmax sadly evaluates to the maximum of a 32 bit signed integer. The obvious next option is uint64(), which contains the forbidden characters. The alternative is to use a function that takes a string as a data type. Obvious candidates are intmax and cast, but alternatives include zeros, ones and eye.

eye(['~rw}?='-9 ''])/0    % Winning version! 22 bytes.
intmax(['~rw}?='-9 ''])   % Obvious candidate. 23 bytes.
1/zeros(['~rw}?='-9 ''])  % 24 bytes
cast(Inf,['~rw}?='-9 '']) % 25 bytes. Also an obvious candidate, but actually very long.

Note: MATLAB is installed by default on virtually all dodgy gambling sites.


JavaScript, 39 38 33 32 bytes


Edit: Saved 5 bytes thanks to @Arnauld.

  • 2
    \$\begingroup\$ Remove alert as this can be run in a console. \$\endgroup\$ – Alexis Tyler Feb 23 '17 at 14:14

PowerShell, 29 14 bytes


Try it online!

Thanks to @n0rd for essentially golfing this in half.

This leverages the inbuilt unary PB operator that basically functions as "multiply the preceding number by 1125899906842624" (i.e., how many bytes are in a pebibyte). That's coupled with the hex 0xC000, or 49152, so 49152 pebibytes. We divide that by 3, yielding 18446744073709551616, and subtract 3/3 to get the final value.

  • \$\begingroup\$ "0x$(7-3)000PB-9/9"|iex \$\endgroup\$ – n0rd Feb 23 '17 at 6:41
  • 3
    \$\begingroup\$ 0xC000PB/3-3/3 \$\endgroup\$ – n0rd Feb 23 '17 at 6:46
  • \$\begingroup\$ @n0rd Oh, that's dang clever, using PB like that. Thanks! \$\endgroup\$ – AdmBorkBork Feb 23 '17 at 13:24
  • \$\begingroup\$ @n0rd pretty impressive, welcome to PPCG! \$\endgroup\$ – colsw Feb 23 '17 at 13:37

BF, 108 bytes


If each command is considered as 3 bits, this is potentially 41 bytes.

  • 3
    \$\begingroup\$ Each command is one byte. Not 3 bits. \$\endgroup\$ – mbomb007 Feb 21 '17 at 14:45
  • \$\begingroup\$ Well yes, that's why I put it as 108 bytes... \$\endgroup\$ – Timtech Feb 21 '17 at 15:32
  • \$\begingroup\$ Yeah, but you said "this is potentially 41 bytes", which it's not. \$\endgroup\$ – mbomb007 Feb 21 '17 at 15:56
  • \$\begingroup\$ An interpreter could be made to interpret 3-bit groups as one of eight commands +-<>[]., \$\endgroup\$ – Timtech Feb 21 '17 at 15:56
  • \$\begingroup\$ That already exists. It's called esolangs.org/wiki/Binaryfuck \$\endgroup\$ – mbomb007 Feb 21 '17 at 15:57

Retina, 28 27 bytes

Saved 1 byte thanks to Kritixi Lithos


Try it online!



Replaces the non-existent/empty input with this string. This particular string was generated by the "inverse" of this program. It encodes a through j as 0 through 9, respectively.


This is a Transliteration stage. The l and d are character sets used for transliteration. l represents the lowercase alphabet, d is all digits. So, it maps abcdefghij back to 0123456789.


JavaScript (ES6), 50 bytes

  • 1
    \$\begingroup\$ You can change the characters to '䠎ᴐIF╏ɧ' and remove the -27 \$\endgroup\$ – powelles Feb 22 '17 at 19:25
  • \$\begingroup\$ @jdp Nice one, thanks :) \$\endgroup\$ – George Reith Feb 23 '17 at 14:20

C++, 46 bytes.

int m(){std::cout<<unsigned long long(5+3-9);}

First time ever doing a code golf, but I'm fairly happy with myself. Will happily take any critique/suggestions :)


Brain-Flak, 64, 62, 58, 54 bytes


Try it online!

[Try it online!]

Four bytes saved thanks to @Riley!


#Push a 64

#While true

  #Pop the top of the stack. We'll store this value for later, but first

  #Before pushing the value

    #Push (N + 1) * 2 - 1
    # (where N is the number underneath, originally 0)


  #And push the TOS minus one back on


#Pop the zero left over

#And decrement the number underneath

For the record, I tried pushing 32 and quadrupling, but it's the same byte count.


C# 6, 31 bytes


Pretty much the same as Java.

C# 5, 56 bytes

class P{static void Main(){System.Console.Write(~0UL);}}
  • \$\begingroup\$ The C# 6 answer is only an anonymous action, which are also present in C# 5. \$\endgroup\$ – TheLethalCoder Feb 21 '17 at 16:03
  • \$\begingroup\$ Also the challenge only asks you to output the number so you could compile to a Func<ulong> as: ()=>~0UL; \$\endgroup\$ – TheLethalCoder Feb 21 '17 at 16:05
  • \$\begingroup\$ It also doesn't say that you can't use any input so you could compile to a Func<int, ulong> to save a byte: _=>~0UL; and I think it would still be valid. \$\endgroup\$ – TheLethalCoder Feb 21 '17 at 16:06

Forth (gforth), 11 9 7 bytes

true U.

Try it online

true is the same as -1. U. prints a number as an unsigned integer.

This works on TIO, possibly because it has a 64-bit architecture? I'm not sure. If I run -1 U. on repl.it, for example, I get 2**32-1. If repl.it supported double-length integers, outputting them would use UD. instead.

  • \$\begingroup\$ You can probably reduce this to -3 3 / U. \$\endgroup\$ – zeppelin Feb 21 '17 at 16:23
  • \$\begingroup\$ Or, even better: true U. (which also rhythms nicely) \$\endgroup\$ – zeppelin Feb 21 '17 at 16:25
  • \$\begingroup\$ Oh, I forget about true, because I'm so used to using 0 and 1. Thanks. \$\endgroup\$ – mbomb007 Feb 21 '17 at 16:27

Python3 REPL, 11 bytes


How it works

  • ~0 is -1 (two's complement, an infinite sequence of '1's)
  • 077 is 63 in octal, so ~077 is -64
  • Shift right with negative parameter is a shift to the left
  • Putting all together, -1 xor (-1 << 64) is the number we are looking for

Swift, 8 bytes


outside playground / repl - 15 bytes


x64 Assembly, 7 bytes

hex (assembled): 4831C048FFC8C3

disassembled, commented:
XOR RAX,RAX ;Zero the value of 64 bit register RAX DEC RAX ;Decrement the value of RAX RET ;Return this value

RAX is a 64 bit register, and is most often used to return integer arguments (eg, C). By decrementing 1, its value rolls over from 0 to... 2^64-1, which is exactly needed.
Though, the assembled binary contains ones and fours and eights, the assembly doesn't, but the assembled file is counted in assembly, so does it count? Ow, my head.
Also, output is return value in this case.


Brain-Flak, 223 193 bytes

Includes +1 for -A
-30 thanks to DJMcMayhem


Try it online!

This just pushed the ASCII values of and prints as characters.

For reference, it takes 338 bytes to generate the actual number using the Integer meta golfer.


Try it Online!


MATL, 8 bytes


This could probably be improved, but I'm not familiar with strings and types in MATL just yet.

Try it at matl.suever.net


l       % push 1
_       % unary minus
5       % push 5, corresponds to type 'uint64'
Z%      % convert 1 to this type
E       % double
ZD      % display as a string
  • \$\begingroup\$ It'd need to be YY5Z%ZD to force uint64 type, but I don't know why using 1 5Z% instead just works... \$\endgroup\$ – B. Mehta Feb 21 '17 at 14:12
  • \$\begingroup\$ You can't use 8. \$\endgroup\$ – xnor Feb 21 '17 at 14:13
  • \$\begingroup\$ @xnor Oops, fixed. \$\endgroup\$ – B. Mehta Feb 21 '17 at 14:16
  • \$\begingroup\$ Can you add a demo link using either matl.suever.net or matl.tryitonline.net? \$\endgroup\$ – Suever Feb 21 '17 at 21:53
  • 1
    \$\begingroup\$ @LuisMendo Ah, of course - I thought cast was used, but it makes sense if typecast is used. Thanks for clearing that up. \$\endgroup\$ – Sanchises Feb 24 '17 at 10:55

Javascript 55 bytes


the code generates and then alerts the string 18446744073709551615 using bitwise operations

590300>>5 18446
59530-3>>3 7440
3*59*73>>3 1615

  • \$\begingroup\$ Displays 2588673709551615 for me... \$\endgroup\$ – n0rd Feb 23 '17 at 19:11
  • \$\begingroup\$ alert(0xafebff0+'7370955'+(3*59*73>>3)) works fine \$\endgroup\$ – n0rd Feb 23 '17 at 19:12
  • \$\begingroup\$ I am leaving it as it is for the sake of keeping the method used instead of just copying someone else now. \$\endgroup\$ – fəˈnɛtɪk Feb 23 '17 at 19:20

JavaScript, 50 bytes 47 bytes

  • \$\begingroup\$ Why do you append the answer to ''? \$\endgroup\$ – Marie Jul 23 '18 at 12:33
  • \$\begingroup\$ @Marie it doesn't: repl.it/repls/SubstantialNoisyRectangle \$\endgroup\$ – Tymek Jul 23 '18 at 12:36
  • \$\begingroup\$ You misunderstood. Why does your code start with ''+? Unless I am missing something, which is possible, you dont need that. \$\endgroup\$ – Marie Jul 23 '18 at 12:51
  • \$\begingroup\$ ah, ok. I didn't read the requirements right. It can be "either a number, or a single string". Thank you \$\endgroup\$ – Tymek Jul 23 '18 at 12:54
  • 1
    \$\begingroup\$ Lol, I didnt notice that but my actual point was that btoa returns a string so either way the result should be a string. \$\endgroup\$ – Marie Jul 23 '18 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.