# Golfing Eratosthenes

**URL:** <https://www.ruby-forum.com/t/golfing-eratosthenes/101063>\
**Category:** Ruby\
**Created:** [August 3, 2006, 12:09pm UTC](https://www.ruby-forum.com/t/golfing-eratosthenes/101063 "2006-08-03T12:09:20Z")\
**Posts on this page:** 1\
**Page:** 2

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [August 3, 2006, 12:52pm UTC](https://www.ruby-forum.com/t/golfing-eratosthenes/101063/21 "2006-08-03T12:52:00Z")

</div>

On Wed, Aug 02, 2006 at 06:20:05PM +0900, William J. wrote:

> > > definition of the array a, and do the whole thing with no semicolons.
> 
> p (2…100).inject([]){|a,n|a.any?{|i|n%i==0}?a:a\<\<n}

Of course, one might make a case for making that (2…99), shaving off a  
byte, since we all know 100 isn’t prime. We could make that 99 lower,  
but there’s no point if our point is golfing.

[Previous page](https://www.ruby-forum.com/t/golfing-eratosthenes/101063.md?page=1)
