Infinitely Print Zeno's Dichotomy Paradox (1/(2^n))

An infinite number of mathematicians walk into a bar. The first one orders a beer. The second one orders half a beer. The third one orders a fourth of a beer. The bartender stops them, pours two beers and says, "You're all a bunch of idiots."

Reddit

Print the following series for as long as the program runs, with the denominator of each item being multiplied by two each time:

1 + 1/2 + 1/4 + 1/8 + 1/16 + 1/32 + ...

As n approaches infinity, the sum of this sequence approaches 2.

Rules

No, you may not print 2.

You may not print 1/1 as the first item.

You may remove spaces 1+1/2+... or add spaces 1 + 1 / 2 + ... as you need.

You may use newlines instead of spaces as a delimiter due to popular demand.

You may append a . plus a constant number of 0s to the denominator if need be.

"Infinitely" means no unnecessary delays, and for as long as possible limited by the current (variable) system's specs, but not limited by your current language.

Standard loopholes apply.

This is , so shortest answer in bytes wins.

• Regarding the joke, I like the "You guys should know your limits" version better. May 16, 2017 at 13:17
• Is it just me, or is that a parabola right there?
May 16, 2017 at 14:17
• @StephenS Yes, I saw them too, but this one is much clearer and bigger.
May 16, 2017 at 14:22
• @Adám: yep! If the lengths of the denominators weren't changing, then the visual pattern of +1/s would just form a diagonal line. However, the lengths of the denominators is changing linearly (up to rounding): the number of digits of 2^n is about n log(2)/log(10). That linear change translates into a linear change in the relative position of each +1/ with respect to the preceding one, which is the same as a quadratic change in the absolute position. May 16, 2017 at 17:02
• @QPaysTaxes then you are non-competing - but if multiple people want to post competing C answers, you can compete against each other :) May 16, 2017 at 23:21

Fourier, 20 bytes

1~io(43a1o47ai*2~io)


Try it online!

I think this may only work on Try it Online due to differences in how Python and Javascript handle large numbers.

Explanation Psuedocode:

i = 1
Print i
While i != 0
Print "+1/"
i = i * 2
Print i
End While

• Can you not move the Print i to the start of the While loop?
– Neil
May 16, 2017 at 15:00
• @Neil I could, but it wouldn't say any bytes May 16, 2017 at 15:32
• Oh, I see now, you're not actually printing i.
– Neil
May 16, 2017 at 15:37

Ruby 46 bytes

i=1;loop{print (i<2?"#{i}":"1/#{i}")+"+";i*=2}


any improvement suggestions are welcome -))

F#, 39 bytes

let rec f x=printf"%A+1/"x;x*2I|>f
f 1I


Try it online!

Labyrinth, 25 bytes

)
:}!43.4
"     9
*{2.74.


Try it online!

Common Lisp, 42 bytes

(do((x 1(* x 2)))(())(format t"~a+"(/ x)))


Try it online (TIO will show you partial output)

Explanation

(do ... )          ;looping
((x 1(* x 2))      ;define x as 1 and then in new interation steps
;as result of 2 * x
(())               ;no ending condition
(format t"~a+"...) ;print argument and "+"
(/ x)              ;divide 1 by x - output is like this: 1, 1/2, 1/4, ...


for($a=.5;$a*=2;)echo"$a+1/";  Ruby, 24 bytes a=1;a/=2r while$><<a<<?+


Try it online!

Heavily based on G B's answer. But rationals are fun :V

GNU Make, 45 57 bytes

Using shell:

$(eval 1?=1)$(info $1+1/)$(call $0,$(shell expr $1 \* 2))  Using GMSL (a lot slower, calculates in unary), a complete makefile — 66 bytes: include gmsl P=$(info $1+/)$(call P,$(call double,$1))
$(call P,1)  MSX-BASIC, 36 bytes 1?"1+":X=2 2?"1/";X;"+":X=X*2:GOTO2  It works up to 70368744177664, then it starts displaying the values in exponential notation due to the precision limitation of the language, then it overflows at 1e62. Taxi, 916 bytes 2 is waiting at Starchild Numerology.'1' is waiting at Writer's Depot.Go to Writer's Depot:w 1 r 3 l 2 l.Pickup a passenger going to Post Office.Go to Post Office:n 1 r 2 r 1 l.Go to Starchild Numerology:s 1 r 1 l 1 l 2 l.Pickup a passenger going to Cyclone.Go to Cyclone:e 1 l 2 r.[r]Pickup a passenger going to Trunkers.Pickup a passenger going to Multiplication Station.Go to Trunkers:s 1 l.Go to Multiplication Station:e 1 r 4 l.Pickup a passenger going to Cyclone.Go to Cyclone:s 1 r 2 l 2 r.Pickup a passenger going to Multiplication Station.Pickup a passenger going to The Babelfishery.' + 1/' is waiting at Writer's Depot.Go to Writer's Depot:s.Pickup a passenger going to Post Office.Go to The Babelfishery:n 1 r 2 r 1 r.Pickup a passenger going to Post Office.Go to Fueler Up:n.Go to Post Office:s 1 r 1 l.Go to Trunkers:s 1 r 1 l.Pickup a passenger going to Cyclone.Go to Cyclone:w 2 r.Switch to plan "r".  Try it online! (TIO will output the first 893 terms (up to ~3.3×10²⁶⁸) before cutting it off.) Ungolfed: 2 is waiting at Starchild Numerology. '1' is waiting at Writer's Depot. Go to Writer's Depot: west 1st right 3rd left 2nd left. Pickup a passenger going to Post Office. Go to Post Office: north 1st right 2nd right 1st left. Go to Starchild Numerology: south 1st right 1st left 1st left 2nd left. Pickup a passenger going to Cyclone. Go to Cyclone: east 1st left 2nd right. [r] Pickup a passenger going to Trunkers. Pickup a passenger going to Multiplication Station. Go to Trunkers: south 1st left. Go to Multiplication Station: east 1st right 4th left. Pickup a passenger going to Cyclone. Go to Cyclone: south 1st right 2nd left 2nd right. Pickup a passenger going to Multiplication Station. Pickup a passenger going to The Babelfishery. ' + 1/' is waiting at Writer's Depot. Go to Writer's Depot: south. Pickup a passenger going to Post Office. Go to The Babelfishery: north 1st right 2nd right 1st right. Pickup a passenger going to Post Office. Go to Fueler Up: north. Go to Post Office: south 1st right 1st left. Go to Trunkers: south 1st right 1st left. Pickup a passenger going to Cyclone. Go to Cyclone: west 2nd right. Switch to plan "r".  Explanation: Pickup the string 1 and print it to stdout to get started. Pickup the number 2 and duplicate it so we have one to keep around and one to print. Abuse the truncation function to leave a 2 for later. (It's en route and has a short name so it saves bytes which is really important in Taxi.) Go multiply the running total by 2. (The first time, it's just a 2 so it returns itself. After that, it's 2 times the running total.) Pickup the string  + 1/. Convert the multiplication result from a number to a string. Get gas. Print the string  + 1/ and the string multiplication result to stdout. Go pickup that 2 from Trunkers, copy it again, and go back to [r].  The output has trailing zeros on every number: 1 + 1/2.000000 + 1/4.000000 + ... but, per a comment by OP, that's OK so long as it's the same number of zeros every time. Lua 5.1 + BC, 50 bytes Now works with arbitrary long integers. I don't usually golf in Lua, so any tips are welcome i=1::a::print(i,'+1/')i=require"bc".mul(i,2)goto a  • You can omit some newlines to save bytes. May 16, 2017 at 12:55 • You can use while 1 do instead. May 16, 2017 at 12:57 • @LeakyNun that will output garbage in the output when overflow happens May 16, 2017 at 12:58 • But then your answer does not print infinitely... May 16, 2017 at 13:00 • @LeakyNun original spec said thar language limitation could end the execution as well, i'll check May 16, 2017 at 13:01 Cubix, 26 bytes oruUroorp"/1+"1>O2uw"wo;;q  A fairly linear program. Push characters /1+ onto the stack, push 1 onto the stack. Start loop, output number, multiply it by 2, push it to the bottom, pop the multipliers, output the characters on the stack and loop. Try it here Maps to  o r u U r o o r p " / 1 + " 1 > O 2 u w " w o ; ; q * . . . . . . . . . . . . . . . . . . . . . . . . . . .  Clojure, 59 bytes #((fn[n](print(if(= 1M n)1(str 1\/ n))\+)(recur(* n 2)))1M)  A function that prints the fraction, doubles the denominator, then recurses. (defn zenos-dichotomy-paradox [] ; Create an anonymous function... ((fn [n] ; ... that prints the fraction (or just 1 if (= n 1))... (print (if (= 1M n) 1 (str 1 \/ n)) \+) ; ..., doubles the denominator, then recurses infinitely. ; Will not SO since I'm using recur. (recur (* n 2))) ; Start the recursive function off with a 1. The M makes it a BigInteger so ; I don't get an IntegerOverflow. 1M))  Outputs 1 +1/2 +1/4 +1/8 +1/16 +1/32 +1/64 +1/128 +1/256 +1/512...  I can make the spacing more consistent at the cost of 2 bytes if necessary. I tried to be clever and abuse Clojure's built in Ratio number type, but I got an overflow pretty quickly. 1/1 would have been automatically simplified to 1, getting rid of 1 as a special case. It would have been nice. Husk, 9 bytes J'+ms:1İ½  Try it online! due to a lack of a 0 term, 1 is manually prepended. MathGolf, 9 bytes ïóoù+1/q∟  Try it online. Explanation:  ∟ # Do-while true without popping: ï # Push the 0-based loop index ó # Pop and push 2 to the power this index o # Output it with trailing newline (without popping) ù+1/ # Push string "+1/" q # Pop and push without trailing newline  Unfortunately MathGolf doesn't output implicitly even if it errors when we stop the infinite program, otherwise the o and q would have been unnecessary, because everything on the stack is joined and output implicitly at the end of a (properly terminating) MathGolf program. Perl 5-Mbigint, 26 bytes print 2**$_++,'+1/'while 1


Try it online!

Using bigint means that this could go on forever without turning into a floating point exponential format, given enough time and RAM. TIO gets to about 1/2922 before cutting off due to the 128 KiB output limit.

Stax, 7 bytes

â─$∩√Öu  Run and debug it same idea as 05AB1E, but Stax has more convenient output here :) Explanation Wi^p"+1/ W loop forever i^ increment counter p print without newline "+1/ print "+1/" without newline  Factor, 33 bytes 1 [ dup "%u+" printf 2 / t ] loop  Try it online! • 1 Push 1 to the stack. • [ ... t ] loop The shortest infinite loop available in Factor. • dup "%u+" printf Non-destructively write the prettyprinted form of an object with a "+" afterward. • 2 / Divide by two. In Factor, / produces an exact ratio as long as its inputs are rational. Use /i for integer division or /f to force the result to be a float. Zephyr, 52 bytes set i to 1 while 1=1 print i,"+" set i to i/2 repeat  Try it online! Gotta love built-in rational numbers. For +3 bytes, output with all spaces (no newlines): Try it online! Mathematica, 45 bytes Row@Flatten@Table[{1/2^t,"+"},{t,0,Infinity}]  • This will not finish computing, and nothing will be printed. May 16, 2017 at 13:53 • Yes, I made it this way in order to get the result in a row. If you want to see a result just test for a finite number. Do you have any other ideas of how to print in a row? May 16, 2017 at 14:03 • You can use newlines as delimiters May 16, 2017 at 14:05 cQuents, 13 bytes |+1/=1:2^($-1


Try it online!

Explanation

|+1/            Set sequence join to "+1/"
=1          Set first item in sequence to 1
:         Mode : (sequence)
2^(\$-1   Each item in the sequence equals 2 to the power of the index (1-based) of the current item minus 1
)  Implicit closing parenthesis