The Programming Language

Language Goals

How it looks

# Compute prime numbers up to 100 with the Sieve of Eratosthenes
max = 100

sieve = Array.new(max + 1, true)
sieve[0] = false
sieve[1] = false

(2...max).each do |i|
  if sieve[i]
    (2 * i).step(max, i) do |j|
      sieve[j] = false
    end
  end
end

sieve.each_with_index do |prime, number|
  puts number if prime
end

Status

Community

Post a question or suggest something in our Google Group or join our IRC channel #crystal-lang at irc.freenode.net

Latest entries from our blog

&.

to_proc

Shortcut syntax for writing one-argument blocks

Hi

Hello World

The famous Hello World program written in different ways in Crystal