Skip to content

Instantly share code, notes, and snippets.

# Calculate all the primes between 0 and the value specified
def primes(up_to)
prev = []
(2..up_to).select do |x|
max_p = Math.sqrt(x).truncate
if !prev.find { |y| y <= max_p ? x % y == 0 : break }
prev << x
end
end
end
<html>
<head>
<title>Getting the gist of Gist</title>
</head>
<body>
like a fox
</body>
</html>