How to resolve the algorithm Strong and weak primes step by step in the Maple programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Strong and weak primes step by step in the Maple programming language
Table of Contents
Problem Statement
Note that the definition for strong primes is different when used in the context of cryptography.
Show all output here.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Strong and weak primes step by step in the Maple programming language
Source code in the maple programming language
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)
You may also check:How to resolve the algorithm Loops/Infinite step by step in the Lisaac programming language
You may also check:How to resolve the algorithm Hello world/Newline omission step by step in the Oforth programming language
You may also check:How to resolve the algorithm Vector step by step in the jq programming language
You may also check:How to resolve the algorithm Sequence: smallest number greater than previous term with exactly n divisors step by step in the Julia programming language
You may also check:How to resolve the algorithm XML/DOM serialization step by step in the Groovy programming language