Mine
public text v1 · immutable$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