Sophie

Sophie

distrib > Fedora > 15 > x86_64 > by-pkgid > 1e007a96761035f261351a68e7601417 > files > 552

parrot-docs-3.6.0-2.fc15.noarch.rpm

#!/usr/bin/ruby

i6 = 0
i7 = 0
max = 500

def is_prime(n)
	if n < 1
		return false
	end

	(n-1).downto(2) { |i|
		if n % i == 0
			return false
		end
	}
	true
end

max.times { |i|
	if is_prime i
		i6 += 1
		i7 = i
	end
}
puts "# of primes calculated to #{max}: #{i6}"
puts "last is: #{i7}"