Sophie

Sophie

distrib > Mageia > 1 > i586 > by-pkgid > d92aa75c2d384ff9f513aed09a46f703 > files > 528

parrot-doc-3.1.0-2.mga1.i586.rpm

#! 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}"