27 lines
627 B
Text
27 lines
627 B
Text
ispernicious := proc(n::posint)
|
|
return evalb(isprime(rhs(Statistics:-Tally(StringTools:-Explode(convert(convert(n, binary), string)))[-1])));
|
|
end proc;
|
|
|
|
print_pernicious := proc(n::posint)
|
|
local k, count, list_num;
|
|
count := 0;
|
|
list_num := [];
|
|
for k while count < n do
|
|
if ispernicious(k) then
|
|
count := count + 1;
|
|
list_num := [op(list_num), k];
|
|
end if;
|
|
end do;
|
|
return list_num;
|
|
end proc:
|
|
|
|
range_pernicious := proc(n::posint, m::posint)
|
|
local k, list_num;
|
|
list_num := [];
|
|
for k from n to m do
|
|
if ispernicious(k) then
|
|
list_num := [op(list_num), k];
|
|
end if;
|
|
end do;
|
|
return list_num;
|
|
end proc:
|