All pastes #1258438 Raw Edit

Mine

public text v1 · immutable
#1258438 ·published 2008-11-16 23:48 UTC
rendered paste body
$primes = [ 1, 2, 3 ]

def isPrime( num )
  test = 1 
  while ( $primes[test] != nil)
    if num % $primes[test] != 0 
      test += 1
    else
      return false
    end
  end
  return true
end

i = 4

#puts 'Please enter the top value for the range you want: '
#j = gets.to_i
j = 1000000

while ( i <= j)
  if isPrime( i )
    $primes.push i
  end
  i += 1
end

#puts $primes
puts 'Number of primes from 0 to ' + j.to_s + ': ' + $primes.length.to_s