RosettaCodeData/Task/Pernicious-numbers/Phix/pernicious-numbers.phix
2017-09-25 22:28:19 +02:00

28 lines
507 B
Text

function is_prime(atom n)
if n<2 then return false end if
for i=2 to floor(sqrt(n)) do
if mod(n,i)=0 then return false end if
end for
return true
end function
function pernicious(integer n)
return is_prime(sum(int_to_bits(n,32)))
end function
sequence s = {}
integer n = 1
while length(s)<25 do
if pernicious(n) then
s &= n
end if
n += 1
end while
?s
s = {}
for i=888_888_877 to 888_888_888 do
if pernicious(i) then
s &= i
end if
end for
?s