Skip to main content
added 23 characters in body
Source Link
hyperneutrino
  • 42.8k
  • 5
  • 72
  • 227

Python 3, 8078 bytes

from fractions import* v=i=Fraction(1) while 1:v+=i+=1;v-=(v+1v>1/i<1i!=print(i)or-1)/i;i+=1i 

Try it online!Try it online!

-8 bytes thanks to ovs
-1 byte thanks to Jo King (the number can't be exactly 1, also thanks to Bubbler for the pseudo-proof of this)
-2 bytes thanks to att

Python 3, 80 bytes

from fractions import* v=i=Fraction(1) while 1:v+=(v+1/i<1!=print(i)or-1)/i;i+=1 

Try it online!

-8 bytes thanks to ovs
-1 byte thanks to Jo King (the number can't be exactly 1, also thanks to Bubbler for the pseudo-proof of this)

Python 3, 78 bytes

from fractions import* v=i=Fraction(1) while 1:i+=1;v-=(v>1/i!=print(i)or-1)/i 

Try it online!

-8 bytes thanks to ovs
-1 byte thanks to Jo King (the number can't be exactly 1, also thanks to Bubbler for the pseudo-proof of this)
-2 bytes thanks to att

added 113 characters in body
Source Link
hyperneutrino
  • 42.8k
  • 5
  • 72
  • 227

Python 3, 8180 bytes

from fractions import* v=i=Fraction(1) while 1:v+=(v+1/i<=1i<1!=print(i)or-1)/i;i+=1 

Try it online!Try it online!

-8 bytes thanks to ovs
-1 byte thanks to Jo King (the number can't be exactly 1, also thanks to Bubbler for the pseudo-proof of this)

Python 3, 81 bytes

from fractions import* v=i=Fraction(1) while 1:v+=(v+1/i<=1!=print(i)or-1)/i;i+=1 

Try it online!

-8 bytes thanks to ovs

Python 3, 80 bytes

from fractions import* v=i=Fraction(1) while 1:v+=(v+1/i<1!=print(i)or-1)/i;i+=1 

Try it online!

-8 bytes thanks to ovs
-1 byte thanks to Jo King (the number can't be exactly 1, also thanks to Bubbler for the pseudo-proof of this)

deleted 526 characters in body
Source Link
hyperneutrino
  • 42.8k
  • 5
  • 72
  • 227

Python 3, 8981 bytes

from fractions import* v=0 i=2v=i=Fraction(1) while 1:j=Fractionv+=(1,i);v+=v+j>1and-j or printv+1/i<=1!=print(i)or j;i+=1-1)/i;i+=1 

Try it online!Try it online!

Outputs the sequence indefinitely.-8 bytes thanks to ovs

# Import the fractions module, specifically the Fraction class from fractions import * # Keep the cumulative sum v = 0 # Keep the current denominator i = 2 # Output forever while True: # Set j to 1 / i as a precise fraction using the stdlib module j = Fraction(1, i) if v + j > 1: # if adding would exceed, subtract instead v += -j else: # otherwise, print and add print(i) v += j i += 1 

Python 3, 89 bytes

from fractions import* v=0 i=2 while 1:j=Fraction(1,i);v+=v+j>1and-j or print(i)or j;i+=1 

Try it online!

Outputs the sequence indefinitely.

# Import the fractions module, specifically the Fraction class from fractions import * # Keep the cumulative sum v = 0 # Keep the current denominator i = 2 # Output forever while True: # Set j to 1 / i as a precise fraction using the stdlib module j = Fraction(1, i) if v + j > 1: # if adding would exceed, subtract instead v += -j else: # otherwise, print and add print(i) v += j i += 1 

Python 3, 81 bytes

from fractions import* v=i=Fraction(1) while 1:v+=(v+1/i<=1!=print(i)or-1)/i;i+=1 

Try it online!

-8 bytes thanks to ovs

Source Link
hyperneutrino
  • 42.8k
  • 5
  • 72
  • 227
Loading