Sieve of Eratosthenes

Generate all prime numbers up to n using the Sieve of Eratosthenes algorithm.

Code

Algorithms
require 'prime'
Prime.each(n).to_a

Parameters

Upper limit

Server

More Ruby Snippets