Some sleep commands implement a delay of an integer number of seconds. However, 232 seconds is only about 100 years. Bug! What if you need a larger delay?

Make a program or a function which waits for 1000 years, with an error of less than ±10%. Because it's too time-consuming to test, please explain how/why your solution works! (unless it's somehow obvious)

You don't need to worry about wasting CPU power - it can be a busy-loop. Assume that nothing special happens while your program waits - no hardware errors or power failures, and the computer's clock magically continues running (even when it's on battery power).

What the solution should do after the sleep is finished:

  • If it's a function: return to caller
  • If it's a program: terminate (with or without error) or do something observable by user (e.g. display a message or play a sound)

45 Answers 45


MATL, 6 5 bytes


This waits for 34359738368 seconds, which is a little more than 1089 years and a half.

Don't try it online!


35     % Push 35
W      % 2 raised to that. Gives 34359738368
Y.     % Pause for that many seconds
  • 2
    \$\begingroup\$ I doubt anyone will find any way that beats this. Then again, I'm surprised to see it this short, so I could be surprised again. The only way I can think of is if another language can do basically the same thing but has a 1-character sleep function (as opposed to 2 ["Y."]). \$\endgroup\$ – Aaron Dec 12 '19 at 17:26

C (gcc), 40 36 32 29 26 24 bytes


Try it online!

-3 thanks to @gastropner.

-1 recursive approach thanks to @AZTECCO.

4294967295*7/86400/365.25 ~ 952.69

  • 12
    \$\begingroup\$ Witchcraft! Dark Arts!!! Why is it possible to call a function as it is being declared, and more precisely, how can you give a parameter to a parameterless function??? \$\endgroup\$ – M.Herzkamp Dec 12 '19 at 9:46
  • 14
    \$\begingroup\$ @M.Herzkamp (1) because why wouldn't you be able to? (2) in C, a function defined with an empty parameter list (as opposed to a void parameter list) is treated as a varargs function. \$\endgroup\$ – Sneftel Dec 12 '19 at 10:08
  • 3
    \$\begingroup\$ would be more interested why you think this runs 2^32 times - and not 2^31 times - as an i variable would be predefined as going from -2^31 to (2^31)-1 (signed) and I dont see an unsigned definition \$\endgroup\$ – eagle275 Dec 12 '19 at 12:42
  • 6
    \$\begingroup\$ Is i somehow guaranteed to be initialized to 0? I still operate under the assumption that it should be treated as garbage if not initialized; then again, I frequently have to work with ancient legacy code that still uses old compilers. \$\endgroup\$ – Aaron Dec 12 '19 at 17:07
  • 16
    \$\begingroup\$ @Aaron Globals in C are initialized to 0 \$\endgroup\$ – ceilingcat Dec 12 '19 at 19:10

Python 3 (Excluding CPython on Windows), 28 bytes

import time

Try it online! (Remember to put something in your will so future generations can check that it ended on time.)

time.sleep(seconds) takes either an int or a float.

1000*365.2422*24*60*60/3e10 == 1.051897536 which is an error of less than 10%.

  • 13
    \$\begingroup\$ +1 for the remark about future generations (and also because it is a great answer). \$\endgroup\$ – ElPedro Dec 11 '19 at 21:34
  • 4
    \$\begingroup\$ This does not work in CPython on Windows. time.sleep of CPython only supports sleeping up to 2^32-1 ms = a little bit less than 50 days. (Limit imposed by WinAPI Sleep) \$\endgroup\$ – JiminP Dec 12 '19 at 9:02
  • 32
    \$\begingroup\$ @JiminP Just goes to show you: If you want to run something for a millennium - don't do it on Windows! T_T \$\endgroup\$ – Noodle9 Dec 12 '19 at 10:48

bash, 26 bytes

I think part of the challenge here is to not have a signed 32 bit overflow, so:

ping -i86400 -c365243 t.co

The idea here is to make 1000 years of pings (365243), once per day (86400).

"t.co" is simply a four character internet hostname (in this case, a link shortener). If your local host table has a one character hostname, you can subtract 3 bytes.

  • 10
    \$\begingroup\$ You have more faith in the longevity of IPv4 than I do. \$\endgroup\$ – Caleb Dec 13 '19 at 5:34
  • 3
    \$\begingroup\$ @Caleb: This only has to start today, on a system that will stay up for 1000 years, not continue to do IPv4 DNS lookups. But yes, ping on my GNU/Linux system supports IPv6 addresses (without having to invoke it as ping6), and localhost is ::1 saving 1 byte. ping :: also works, for the IPv6 unspecified address, saving 2 bytes but getting error messages (ping: sendmsg: Network is unreachable). \$\endgroup\$ – Peter Cordes Dec 13 '19 at 8:51
  • \$\begingroup\$ Do you need to ping a working domain? Wouldn't this still work according to spec if all the pings failed by calling a fake domain like t? \$\endgroup\$ – Ferdz Dec 13 '19 at 15:18
  • 3
    \$\begingroup\$ With my version of ping, ping 1 attempts to ping, which saves 3 characters if you can get that IP to ping. \$\endgroup\$ – Vortico Dec 13 '19 at 16:01
  • \$\begingroup\$ @Vortico It does not on my ubuntu 16.04 system and ping does not work on TIO so i wouldn't say this is valid. \$\endgroup\$ – Luc H Dec 13 '19 at 16:24

Ruby, 10 bytes

sleep 3e10

Try it online!

There are approximately \$3*10^{10}\$ seconds in a thousand years.

  • 15
    \$\begingroup\$ sleep 32e9 is more accurate and has the same size in bytes \$\endgroup\$ – G B Dec 13 '19 at 9:13
  • \$\begingroup\$ 31557600000 seconds \$\endgroup\$ – HelloWorld Dec 13 '19 at 12:47
  • 9
    \$\begingroup\$ "Try it online!". LOL \$\endgroup\$ – Eric Duminil Dec 13 '19 at 18:21

PowerShell, 35 32 24 21 19 bytes

1..3e4|%{sleep 1mb}

Try it online!

Strangely, the maximum seconds value for Start-Sleep is 2147483. No, I don't know why it's such an odd value. That works out to a little over 2 megabytes (2097152). 1mb * 30000 / 86400 / 365.25 is 996.821051030497, so a little under 1000 years. I could get more exact using a different value than 3e4, but this is within the allowed margin and I'm lazy.

Saved 3 bytes thanks to ceilingcat.
Saved 8 bytes thanks to Jeff Zeitlin.
Saved 3 bytes thanks to Neil.
Saved 2 bytes thanks to Mark Henderson and Nahuel Fouilleul.

  • 13
    \$\begingroup\$ Well, 2147483 is 1/1000th of a max 32-bit integer, so perhaps Powershell internally does some unit conversions with milliseconds or something. See here (MaxIdleTimeoutSec) \$\endgroup\$ – aphrid Dec 11 '19 at 19:04
  • \$\begingroup\$ Save 8 bytes with 1..15000|%{sleep 2.04mb}. \$\endgroup\$ – Jeff Zeitlin Dec 11 '19 at 19:09
  • 2
    \$\begingroup\$ Why not sleep 2mb? You'll get a little under 1000 years, but other than that it should be fine, I'd have thought? \$\endgroup\$ – Neil Dec 11 '19 at 21:08
  • 2
    \$\begingroup\$ Save yourself an extra byte with 1..15e3 \$\endgroup\$ – Mark Henderson Dec 12 '19 at 3:19
  • 2
    \$\begingroup\$ or 1..3e4 and sleep 1mb \$\endgroup\$ – Nahuel Fouilleul Dec 12 '19 at 7:45

6502 Machine Code on an Apple II, 10 9 bytes

Code is actually platform-independent, other than it relies on the Apple's clock speed of 1.023 MHz for timing.

Code starts at address 0x0000:

0000: A2 CA F6 44 F0 FB D0 F8 F7

Saved an additional byte. Details are below original answer.

Original answer:

Code starts at address 0x0059:

0059: A2 08 F6 60 D0 FA CA D0 F9 F5


loop1: 0059- A2 nn     LDX #$nn   ; 2 cyc
loop2: 005B- F6 60     INC $60,X  ; 6 cyc
       005D- D0 FA     BNE loop1  ; 2-3 cyc
       005F- CA        DEX        ; 2 cyc
       0060- D0 F9     BNE loop2  ; 2-3 cyc
       0062- pp        DB  $pp    ; data byte

This is a fairly simple routine that increments a multi-byte counter. When the counter rolls over, the last branch instruction gets modified so that it points to an RTS instruction, which provides the exit for the routine.

loop1 is taken for each increment of the counter and takes 11 cycles per iteration. loop2 is taken for each byte carried over and takes 13 cycles per iteration. So if we increment the counter N times, we spend approximately:

11*N + 13*(1/256 + 1/(256^2) + 1/(256^3) + ...)*N = 11.05*N cycles

1000 years is 365242*86400*1023000 = 32282717702400000 cycles

So we need N = 2921512914244345 +/- 10%

Or a range of 2629361622819911 - 3213664205668779
= 0x095763F583A447 - 0x0B6ACF816801AB

In the code above, set pp = 0xF5 and nn = 0x08.

This gives us a 7-byte counter in memory locations 0x62-0x68 (with MSB at lowest address, i.e. big endian). Only location 0x62 is initialized, so our starting counter value could be anywhere from 0xF5000000000000 to 0xF5FFFFFFFFFFFF.

We'll increment the counter until it rolls over to 0, which will cause the byte at 0x61 to increment by 1, which happens to be the branch target for loop2. On the first byte carry after rollover-- when the counter hits 0x100-- we'll hit the modified branch instruction for the first time. This will take us to address 0x5C (loop2+1). The 0x60 byte there is the opcode for "Return from Subroutine" (RTS) which provides our exit.

So our total loop count is between, 0x0A000000000101 and 0x0B000000000100, which is a subset of the range we calculated which gives us the necessary number of cycles +/- 10%.

Now that we have the exact starting and ending counter values, we could go back and calculate the exact cycle counts, but given how much margin there is, I'm willing to hand-wave that part.

You can actually test it out with smaller values of nn. For example nn of 4 will pause for several seconds.

9-byte answer:

0000- A2 CA     LDX #$CA   ; 2 cyc
0002- F6 44     INC $44,X  ; 6 cyc
0004- F0 FB     BEQ $0001  ; 2-3 cyc (rollover)
0006- D0 F8     BNE $0000  ; 2-3 cyc (non-rollover)
0008- F7        DB  $F7    ; data byte

Saved one byte by folding the DEX opcode into the argument for LDX.

Instead of 11.05 cycles, each counter increment is now 13 + 11*(1/256 + 1/(256^2) + ...) = 13.043 cycles.

Now we need 2475073064976549 +/- 10% iterations, or a range of 0x7E9F591BF7A2E - 0x9AC2C23EA071C.

So now we initialize the 7-byte counter to something between 0xF7000000000000 and 0xF7FFFFFFFFFFFF. This ends up giving between 0x08000000000001 and 0x09000000000000 loop iterations, which is within the +/-10% needed.

When the counter rolls over to 0, the last branch gets modified to jump to $0001, which leads to an increment of the BNE opcode itself (to a CMP instruction, which for our purpose is effectively a no-op). Code then falls through to $0008, which now contains a 0 (because of counter rollover). A 0 byte is a BRK instruction, which drops you back to the system monitor, ending the routine.


05AB1E, 6 bytes


Inspired by the other answer in 05AB1E.

Waits for 1027/2 milliseconds, or about 1002 years.


27            push the number 27
  ;           divide by 2
   °          replace X by 10 to the power of X
    .W        wait that number of milliseconds

Try it online!

  • \$\begingroup\$ Can you explain this a bit more? How does that translate to 10^(27/2)? \$\endgroup\$ – Aaron Dec 12 '19 at 17:19
  • \$\begingroup\$ Nice approach! I actually just found another 6-byter myself as well. :) \$\endgroup\$ – Kevin Cruijssen Dec 13 '19 at 12:53

Jelly, 8 bytes


Try it online!

A niladic link which waits for 32 seconds 1 billion times. 32,000,000,000 is within 10% of 31,557,600,000 seconds which is 1,000 years (ignoring leap seconds and ignoring the fact that centuries indivisible by 400 are not leap years).


Charcoal, 7 bytes


Try it online! Link is to verbose version of code with a speed up factor of 1e9 (obtained by changing the ⁴ into a a ¹) so that it doesn't time on TIO. Explanation:


Repeat 33 times.


Refresh the screen, but delay 1000⁴ milliseconds between refreshes.

Although there are 33 refreshes, there are only 32 intervals, so the total delay is 32000000000000 milliseconds or approximately 1015 years.

  • 11
    \$\begingroup\$ I love the implications of “Try it online!” It was the year 12019, and the ancient computer finally woke up. Amazed, the engineers used the methods of long-dead programmers to find what was running. The computer said, Charcoal. The gods had spoken, and in that moment, programming became an important force in the world once again. \$\endgroup\$ – BalinKingOfMoria Reinstate CMs Dec 12 '19 at 4:40
  • 13
    \$\begingroup\$ @BalinKingOfMoria 1000 years after now is 3019, not 12019 ;) \$\endgroup\$ – Omega Krypton Dec 12 '19 at 5:16
  • 3
    \$\begingroup\$ @OmegaKrypton The code sleeps for almost 1015 years anyway, so it would wake up some time during 3034. \$\endgroup\$ – Neil Dec 12 '19 at 9:23
  • \$\begingroup\$ @OmegaKrypton Oooops, I misremembered it as 10,000 years facepalm \$\endgroup\$ – BalinKingOfMoria Reinstate CMs Dec 12 '19 at 17:12
  • 1
    \$\begingroup\$ I can't stand cryptic or archaic languages and would prefer everyone forget about them and use ones that are more readable (maybe Charcoal is and this is just an (ab)use of it?), but this still gets +1 for the effort even though it makes me cringe. \$\endgroup\$ – Aaron Dec 12 '19 at 17:14

Java (JDK), 23 bytes


Try it online!

It's hard to find a short way to write a number in Java. Thread.sleep only accepts a long number of milliseconds. So the standard answer 3e10 doesn't work because it's a double. Casting it to a long would be the appropriate action. But it would still be 1000 too small. So enter 3e13 which is closer. But fortunately, 7L<<42 is 30,786,325,577,728, which is close to the actual count of 1000 years, and is a long without cast, so 4 bytes shorter than (long)3e13.


  • -4 bytes thanks to Neil by replacing (long)3e13 with 7L<<42.
  • \$\begingroup\$ @XtremeBaumer No: 3*10^13 = 19. Surely we want to sleep for more than 19 milliseconds. The ^ operator is the binary xor. There is no power operator in Java. Only Math.pow which also returns a double and therefore requires a cast, increasing the total byte count, not decreasing it. \$\endgroup\$ – Olivier Grégoire Dec 12 '19 at 13:42
  • \$\begingroup\$ Does this count here without alle the main class and the try catch for the interruption exception? \$\endgroup\$ – avalancha Dec 12 '19 at 14:10
  • 2
    \$\begingroup\$ @avalancha Consensus is that lambdas are fine. You don't need to try/catch in lambdas since it relies on declaring interfaces that do all that for you. That's why I declared the Sleeper interface in my TIO. We're using several distinct rulings to get this far in golfing in Java. \$\endgroup\$ – Olivier Grégoire Dec 12 '19 at 14:17
  • \$\begingroup\$ awesome, thx for the link! \$\endgroup\$ – avalancha Dec 12 '19 at 14:52
  • 5
    \$\begingroup\$ Can you use 7L<<42? It's about 3e13, I think. \$\endgroup\$ – Neil Dec 13 '19 at 0:41

Batch, 41 25 bytes

-8 bytes thanks to AdmBorkBork
-6 bytes thanks to ceilingcat
-2 bytes thanks to inspiration from Neil

ping 1 -n 31556952000>nul

Using 31,556,952 seconds / year and a (default) 1 second delay between each ping, this will wait 1000 years before returning nothing.

Note that ping 1 results in failure but it'll fail 31 billion times so that still works.

  • 2
    \$\begingroup\$ How about to save two bytes? Sure, it's not a valid "test" address (sorry, Cloudflare), but hey, it's code-golf. ;-) \$\endgroup\$ – AdmBorkBork Dec 11 '19 at 20:19
  • 1
    \$\begingroup\$ Actually, more than that, because you can therefore do -n 31556952000000>nul and skip the -w, since there's a one second delay between each ping. \$\endgroup\$ – AdmBorkBork Dec 11 '19 at 20:33
  • 1
    \$\begingroup\$ Why not, which abbreviates to 1.1? \$\endgroup\$ – Neil Dec 11 '19 at 21:09

APL (Dyalog Unicode), 9 8 bytesSBCS

-1 thanks to Eric Towers.

Full program. This works by observing that $$\sum_{n=1}^{8^6}n=3.44×10^{10}\approx3.16×10^{10}$$which is the number of seconds in a thousand years.


Don't try it online!


ɩntegers until that

⎕dl¨delay each of those many seconds

  • \$\begingroup\$ I don't know APL, but is ⎕dl¨3e10 good for 8 bytes? \$\endgroup\$ – 79037662 Dec 11 '19 at 23:31
  • \$\begingroup\$ @79037662 ¨ is "each" which wouldn't be needed in this case, but no, 3e10 is for some reason too big an argument for ⎕dl which appears to have a limit of 2147483 seconds. \$\endgroup\$ – Adám Dec 11 '19 at 23:37
  • \$\begingroup\$ 8*6 = 262144, giving 1088.8... years. \$\endgroup\$ – Eric Towers Dec 13 '19 at 4:07
  • \$\begingroup\$ @EricTowers Incorporated. Thanks! \$\endgroup\$ – Adám Dec 13 '19 at 8:13

Wolfram Language (Mathematica), 11 bytes


2 to the 35th power is about 8.9% greater than 31,556,926,000.

  • \$\begingroup\$ I’m not at my computer right now to check, but can you save a byte with Pause@2^35 ? \$\endgroup\$ – Michael Stern Dec 15 '19 at 0:15
  • \$\begingroup\$ Tried that—it pauses for 2 seconds and returns Null^35 :D \$\endgroup\$ – Greg Martin Dec 15 '19 at 8:23

T-SQL, 56 bytes

  • The SQL WAITFOR command is limited to 24 hours, so it has to go in a loop.
  • WAITFOR has two options: DELAY that waits a certain length of time, or TIME which waits until a certain time of day. Turns out WAITFOR TIME'9:0' (which will pause until 9am the following day) is a couple of bytes shorter than WAITFOR DELAY'24:0'.
  • Using a GOTO loop is shorter than a WHILE loop.
  • I'm looping 4E5 times (400,000), which is within 10% of the 10-year (365,242 day) goal.
  • If I start it today, this would complete in February, 3115

Lua, 38 bytes

t=os.time;o=t()+2^35while t()<o do end

Try it online!

Being ANSI C compliant, Lua does not implement any sleep functions, so we have to make one ourselves. Oh, and make sure to keep the dust off that One Thousand Year Computer, we're busy waiting.

Lua, 38 bytes

t=os.time;o=t()+2^35repeat until o<t()

Try it online!

Same thing, different loop. Tried to see if I can save some bytes, but nope.

  • 4
    \$\begingroup\$ What the dingle bells, why does 35while not throw the parser into conniptions? Today I learned something about Lua I didn't want to know. \$\endgroup\$ – Caleb Dec 13 '19 at 5:41
  • \$\begingroup\$ @Caleb In upcoming Lua 5.4, this will no longer works. They have learnt this lesson. Also, tio.run really should provide different Lua versions due to significant changes (this one will cause a lot of 5.3 golf break if they'll just update). \$\endgroup\$ – val says Reinstate Monica Dec 13 '19 at 11:04

C# (Visual C# Interactive Compiler), 59 bytes

b=>{for(var d=DateTime.Now.AddYears(999);d>DateTime.Now;);}

Can be tested by replacing AddYears() with AddSeconds()

Try it online!

  • \$\begingroup\$ Couldn't this be shortened by eliminating 'd' and making the 'for' a 'while'? \$\endgroup\$ – bta Dec 14 '19 at 2:06
  • \$\begingroup\$ @bta you mean while (DateTime.Now.AddYears(999) > DateTime.Now); ? but that would result in an endless loop, as if I don't initially store DateTime.Now in a variable it will keep updating it`s value. \$\endgroup\$ – Innat3 Dec 14 '19 at 12:18

R, 24 bytes


Try it online!

A solid starter, feels like there's optimisation to be had with a different function & number combo. This sleeps for 1s, then 2s, then 3s, then 4s... up to 250000s, at which point it's been running for about 990 years and outputs a list of 250k empty elements.

  • 1
    \$\begingroup\$ why not 3e10 like the other answers \$\endgroup\$ – qwr Dec 12 '19 at 22:09
  • \$\begingroup\$ @qwr Sys.sleep(3e10) doesn't work, and I couldn't figure out a shorter way to write some version of for(i in 1:3e10)Sys.sleep(1) that works. If there is one then more fool me! \$\endgroup\$ – CriminallyVulgar Dec 13 '19 at 9:52
  • \$\begingroup\$ @qwr it occurred that there's a less obvious reason for this being the shortest one I found: 25e4 is the same length as 3e10, but sapply allows us to pass the counter into the function without parentheses making it valuable to find a number with sums along to roughly 3e10. The 1:25e4 is doing double duty here. \$\endgroup\$ – CriminallyVulgar Dec 13 '19 at 10:42
  • \$\begingroup\$ why doesn't Sys.sleep(3e10) work? \$\endgroup\$ – qwr Dec 13 '19 at 18:49
  • \$\begingroup\$ I'm not 100% on the why of it, but the documentation says on Windows Sys.sleep uses Sleep. I'm not knowledgeable of the specifics there, but the outcome is that it sleeps for a few milliseconds rather than a thousand years. Might behave differently on Linux? \$\endgroup\$ – CriminallyVulgar Dec 19 '19 at 12:18

Pyth, 10 bytes


Try it online!

There are exactly 31,557,600 seconds in the Julian astronomical year., totalling 31,557,600,000 seconds in 1000 years. 2^32 is about a tenth of this, so we just wait for 3,155,760,000 seconds ten times. Note that is a blank codepoint in the TIO, not sure why it translates to this on SE

Here you can see that C"¼€ is equal to 3,155,760,000

And here is an example that waits for only 22 seconds using a similar method

Pyth, 8 bytes


Try it online!

Alternatively, this one just uses C"XúÃ for 31,557,600,000. I thought it was more in line with the spirit of the challenge to have a 2^32 limit, though

The average length of a sidereal year, however, is 365.256363004 days or around 31,558,149.763 seconds, giving us a total of ~31,558,149,764 seconds in 1000 years. In this case, the more accurate solution would be

This: VT.dC"¼ê@

This:.dC"Y&ƒ(1 byte longer than Julian solution)


Mumps (M): 7 Bytes

H 9**11

Mumps likes single-letter commands & big numbers... H(ang) sleeps for ## of seconds; 9 to the 11th power gives 31381059609 seconds, which is almost 0.6% low for 1000 years; well within the margin of error.

Keeping with the 7 byte code length, I tested "power of 9" sleep times on 2 different Mumps implementations; the largest power of 9 on YottaDB/GT.M I can find without numeric overflow would be:

H 9**49

which gives a sleep time of just over 1,814 decillion millennia. InterSystems' Cache doesn't overflow and can go to:

H 9**99

which gives 9.352x1083 millennia. That's quite a nap in 7 bytes!


Perl 5, 18 bytes

sleep 1e9for 1..30

Try it online!

10 bytes (doesn't work)

sleep 3e10

Try it online!


PHP, 30 bytes

The time() function can be used instead of microtime(1), as when plused with 3e10, PHP converts the value into a float, even when the original value is an int and thereby save some more bytes.


See how php converts values

As stated by "manassehkatz-Reinstate Monica" a flag can be set to make it run without the tags in PHP, so a more clean version is here made. (36 bytes)


Google tells me that 1000 years = 3.1556926 × 1010 seconds (31,556,926,000)
The method cloud even be made recoverable in the event of power failures. (not done in this example)

<?php time_sleep_until(microtime(true)+31556926000)); ?>

The shorter but more imprecise version (45 bytes with the php tags)

<?php time_sleep_until(microtime(1)+3e10); ?>

With a correction from "Kaddath" this option below is dropped as the documentation state that it is a int not a float used in sleep()
It can be done like so:

<?php sleep(31556926000); ?>

Try it online!

  • 2
    \$\begingroup\$ I love how you've added a "Try it online!" link :') \$\endgroup\$ – Martijn Dec 12 '19 at 9:35
  • \$\begingroup\$ I think it would work with 1+"3e10" which saves 3 bytes ;) (automatic conversion to float and actually 31556926000 is already a float, not an int) \$\endgroup\$ – Kaddath Dec 12 '19 at 10:02
  • \$\begingroup\$ Well after having tested, my previous comment's suggestion doesn't work, but that means yours will not either: sleep converts argument to an int, so the value used will be 1492154928 when you use 31556926000, which is "only" 47.3 years (hard to verify, I know, must trust the documentation on this).. Sorry! \$\endgroup\$ – Kaddath Dec 12 '19 at 10:27
  • \$\begingroup\$ However, the second code with time_sleep_until will work, because it uses a float, and there you actually can use microtime(true)+"3e10".. EDIT: even better: microtime(1)+"3e10" \$\endgroup\$ – Kaddath Dec 12 '19 at 10:32
  • 1
    \$\begingroup\$ Congrats Mikki! Thanks for representing PHPers! PS: do you really need the closing tag ?>? ;D \$\endgroup\$ – Victor F Dec 12 '19 at 15:15

JavaScript (Node.js), 70, 67, 34 bytes

-3 thanks to Joost K, see their answer for why I used 8e6
-33 thanks to Benjamin Gruenbaum for pointing out callbacks are better, using the concept of his answer

I've found 2 ways of solving this problem. The first defines a globally:


the other method passes a through each time, using setTimeout's further args:


These solutions remain the same length when using IIFEs or just calling the function manually.

  • \$\begingroup\$ You can remove the space to save another byte :) \$\endgroup\$ – Kevin Cruijssen Dec 13 '19 at 13:04
  • \$\begingroup\$ you can cut down 3 bytes by changing the loop like t=77e5;--t; and using t as the time to wait.setTimeout(r,t) See my C# answer where I use this in C# \$\endgroup\$ – Joost K Dec 13 '19 at 13:39
  • 1
    \$\begingroup\$ @JoostK Clever, I'll add that in now, thanks :) \$\endgroup\$ – Kobe Dec 13 '19 at 14:09
  • 2
    \$\begingroup\$ Same concept but with callbacks instead of promises :] (function f(a){setTimeout(f,--a)})(8e6); at 40 characters \$\endgroup\$ – Benjamin Gruenbaum Dec 13 '19 at 19:13
  • \$\begingroup\$ @BenjaminGruenbaum Wouldn't this carry on forever? and isn't a undefined? \$\endgroup\$ – Kobe Dec 17 '19 at 9:55

Applescript, 10

delay 3e10

Sleeps for 3 * 1010 seconds.


05AB1E, 7 6 bytes


~8.879% too large

Also take a look at this excellent alternative 6-byter by @anatolyg.

Previous 7-byters:

žqþ¨¨.W     # ~0.449% too small
žG14∍.W     # ~3.837% too large
13°3*.W     # ~4.936% too small

For 100% precision (: assuming a year is 365.25 days), use •Tε‚šä¦•.W (10 bytes) instead.


35          # Push 35
  o         # Pop and push 2 to the power 35: 34359738368
   F        # Loop that many times:
    .Z      #  And sleep for 1 second every iteration

žq          # Push PI with 15 decimal digits by default: 3.141592653589793
  þ         # Remove the dot by only leaving the digits: 3141592653589793
   ¨¨       # Remove the last two digits: 31415926535897
     .W     # Sleep that many ms

žG          # Push builtin integer 32768
  14∍       # Extend it to size 14: 32768327683276
     .W     # Sleep that many ms

13°         # Push 10 to the power 13: 10000000000000
   3*       # Multiply it by 3: 30000000000000
     .W     # Sleep that many ms

•Tε‚šä¦•    # Push compressed integer 31557600000000
        .W  # Sleep that many ms

See this 05AB1E tip of mine (section How to compress large integers?) to understand why •Tε‚šä¦• is 31557600000000.

05AB1E is built in Elixir, and its sleep builtin can even hold :infinity apparently, so I can assume the .W has no maximum.

  • 1
    \$\begingroup\$ 5 bytes: ₆9e.W (waits ~8% too long). \$\endgroup\$ – Grimmy Dec 13 '19 at 13:50
  • \$\begingroup\$ @Grimmy Nice, I knew 5 bytes should be possible somehow with some of the 1-byte constants and 1-byte builtins! I was playing around with palindromize, factorize, euler_constant, etc. but forgot about e. Feel free to post it as your own answer in this case, since there are already two 05AB1E answers and my answer is already a bit too full (don't really want to remove the 7 byters). I'll upvote you when you do. \$\endgroup\$ – Kevin Cruijssen Dec 13 '19 at 13:52

05AB1E, 5 bytes


Sleeps for about 1082 years.

Try it online!

₆         # push 36
 9        # push 9
  e       # nPr (number of 9-element permutations of a 36-element list)
   .W     # wait that many milliseconds

SAS, 38 bytes

data;do i=1to 3e10;a=sleep(1);end;run;

This loop seems to be the shortest option as both sleep and wakeup are capped at 46 days - slightly less than 222 seconds. I wonder what the rationale for that was?


JavaScript (Node.js), 34 bytes

uses the 3e13 like most answers but in a for loop. The 1 at the end is to make it a valid for loop.


Try it online!

Don't actually try it...


Roblox, 11 bytes


Waits 30,000,000,000 seconds, which is roughly equal to 950 years.


C# (Visual C# Interactive Compiler), 38 37 bytes

this waits 1 + 2 + 3.. +77e5-1 + 77e5ms.

I got this 77e5 magic number using the formula (x+1)/2*x=3e13 where x results in approximately 7.745.967 which I shortened to 77e5.

To check if it still falls in the allowed range I did 1000*365.25*24*3600*1000/((77e5+1)/2*77e5) which is 1.064 aka 6.45% of target

update : 8e6 results in 0.98 more precise and less bytes.

for(var i=0;i++<8e6;)Thread.Sleep(i);

Try it online!


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.