Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

Ruby 2.6, 42 bytes

->n{(1..).lazy.select{|i|i!=i*1.0}.take n}

Works with 64-bit floats, returns an enumerator.

###Ruby 2.5 and below, 43 bytes

Ruby 2.5 and below, 43 bytes

->n{1.step.lazy.select{|i|i!=i*1.0}.take n}

And finally, the one that actually finishes in reasonable time:

->n{(2**53).step.lazy.select{|i|i!=i*1.0}.take n}

Try it online!

Ruby 2.6, 42 bytes

->n{(1..).lazy.select{|i|i!=i*1.0}.take n}

Works with 64-bit floats, returns an enumerator.

###Ruby 2.5 and below, 43 bytes

->n{1.step.lazy.select{|i|i!=i*1.0}.take n}

And finally, the one that actually finishes in reasonable time:

->n{(2**53).step.lazy.select{|i|i!=i*1.0}.take n}

Try it online!

Ruby 2.6, 42 bytes

->n{(1..).lazy.select{|i|i!=i*1.0}.take n}

Works with 64-bit floats, returns an enumerator.

Ruby 2.5 and below, 43 bytes

->n{1.step.lazy.select{|i|i!=i*1.0}.take n}

And finally, the one that actually finishes in reasonable time:

->n{(2**53).step.lazy.select{|i|i!=i*1.0}.take n}

Try it online!

Source Link
Kirill L.
  • 14.3k
  • 2
  • 17
  • 54

Ruby 2.6, 42 bytes

->n{(1..).lazy.select{|i|i!=i*1.0}.take n}

Works with 64-bit floats, returns an enumerator.

###Ruby 2.5 and below, 43 bytes

->n{1.step.lazy.select{|i|i!=i*1.0}.take n}

And finally, the one that actually finishes in reasonable time:

->n{(2**53).step.lazy.select{|i|i!=i*1.0}.take n}

Try it online!

AltStyle によって変換されたページ (->オリジナル) /