44 lines
897 B
Text
44 lines
897 B
Text
isStrong := proc(n::posint) local holder;
|
|
holder := false;
|
|
if isprime(n) and 1/2*prevprime(n) + 1/2*nextprime(n) < n then
|
|
holder := true;
|
|
end if;
|
|
return holder;
|
|
end proc:
|
|
|
|
isWeak := proc(n::posint) local holder;
|
|
holder := false;
|
|
if isprime(n) and n < 1/2*prevprime(n) + 1/2*nextprime(n) then
|
|
holder := true;
|
|
end if;
|
|
return holder;
|
|
end proc
|
|
|
|
findStrong := proc(n::posint) local count, list, k;
|
|
count := 0; list := [];
|
|
for k from 3 while count < n do
|
|
if isStrong(k) then count := count + 1;
|
|
list := [op(list), k];
|
|
end if;
|
|
end do;
|
|
return list;
|
|
end proc:
|
|
|
|
findWeak := proc(n::posint) local count, list, k;
|
|
count := 0;
|
|
list := [];
|
|
for k from 3 while count < n do
|
|
if isWeak(k) then
|
|
count := count + 1;
|
|
list := [op(list), k];
|
|
end if;
|
|
end do;
|
|
return list;
|
|
end proc:
|
|
|
|
findStrong(36)
|
|
findWeak(37)
|
|
countStrong(1000000)
|
|
countStrong(10000000)
|
|
countWeak(1000000)
|
|
countWeak(10000000)
|