How to resolve the algorithm Semiprime step by step in the Maple programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Semiprime step by step in the Maple programming language
Table of Contents
Problem Statement
Semiprime numbers are natural numbers that are products of exactly two (possibly equal) prime numbers.
Semiprimes are also known as:
(This particular number was chosen as the length of the Arecibo message).
Write a function determining whether a given number is semiprime.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Semiprime step by step in the Maple programming language
Source code in the maple programming language
SemiPrimes := proc( n )
local fact;
fact := NumberTheory:-Divisors( n ) minus {1, n};
if numelems( fact ) in {1,2} and not( member( 'false', isprime ~ ( fact ) ) ) then
return n;
else
return NULL;
end if;
end proc:
{ seq( SemiPrimes( i ), i = 1..100 ) };
{ 4,6,9,10,14,15,21,22,25,26,33,34,35,38,39,46,49,51,55,57,58,62,65,69,74,77,82,85,86,87,91,93,94,95 }
You may also check:How to resolve the algorithm Mutual recursion step by step in the Haskell programming language
You may also check:How to resolve the algorithm Null object step by step in the AmigaE programming language
You may also check:How to resolve the algorithm Semiprime step by step in the Oforth programming language
You may also check:How to resolve the algorithm Circles of given radius through two points step by step in the EasyLang programming language
You may also check:How to resolve the algorithm Draw a sphere step by step in the Tcl programming language