#Код программы на Ruby22 t=[] primes = NumberHelpers::getPrimeNumbers(6288, nil) primes.each do |pr| t << pr if pr >= 5232 and NumberHelpers::GetNumbersSum(pr) % 2 == 0 end p t p t.size
def getPrimeNumbers(max, primes) primes = [2] if primes == nil
for i in (primes.last+1)..max f = false primes.each do |pn| f = (f or (i % pn==0)) end primes<<i if not f end p primes.last return primes end
def GetNumbersSum(n) n = n.to_s.chars sum = 0 n.each do |c| sum += c.to_i() end
54
#Код программы на Ruby22
t=[]
primes = NumberHelpers::getPrimeNumbers(6288, nil)
primes.each do |pr|
t << pr if pr >= 5232 and NumberHelpers::GetNumbersSum(pr) % 2 == 0
end
p t
p t.size
def getPrimeNumbers(max, primes)
primes = [2] if primes == nil
for i in (primes.last+1)..max
f = false
primes.each do |pn|
f = (f or (i % pn==0))
end
primes<<i if not f
end
p primes.last
return primes
end
def GetNumbersSum(n)
n = n.to_s.chars
sum = 0
n.each do |c|
sum += c.to_i()
end
return sum
end