33 lines
754 B
Text
33 lines
754 B
Text
with(NumberTheory):
|
|
with(ArrayTools):
|
|
|
|
isLong := proc(x::integer)
|
|
if irem(10^(x - 1) - 1, x) = 0 then
|
|
for local count from 1 to x - 2 do
|
|
if irem(10^(count) - 1, x) = 0 then
|
|
return false;
|
|
end if;
|
|
end do;
|
|
else
|
|
return false;
|
|
end if;
|
|
return true;
|
|
end proc:
|
|
|
|
longPrimes := Array([]):
|
|
|
|
for number from 1 to PrimeCounting(500) do
|
|
if isLong(ithprime(number)) then Append(longPrimes, ithprime(number)): end if:
|
|
end:
|
|
|
|
longPrimes;
|
|
lpcount := ArrayNumElems(longPrimes):
|
|
numOfLongPrimes := Array([lpcount]):
|
|
for expon from 1 to 7 do
|
|
for number from PrimeCounting(500 * 2^(expon - 1)) + 1 to PrimeCounting(500 * 2^expon) do
|
|
if isLong(ithprime(number)) then lpcount += 1: end if:
|
|
end:
|
|
Append(numOfLongPrimes, lpcount):
|
|
end:
|
|
|
|
numOfLongPrimes;
|