How to resolve the algorithm Semiprime step by step in the Action! programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Semiprime step by step in the Action! 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 Action! programming language
Source code in the action! programming language
BYTE FUNC IsSemiPrime(INT n)
INT a,b
a=2 b=0
WHILE b<3 AND n#1
DO
IF n MOD a=0 THEN
n==/a b==+1
ELSE
a==+1
FI
OD
IF b=2 THEN
RETURN(1)
FI
RETURN(0)
PROC Main()
INT i
PrintE("Semiprimes:")
FOR i=1 TO 500
DO
IF IsSemiPrime(i) THEN
PrintI(i) Put(32)
FI
OD
RETURN
You may also check:How to resolve the algorithm AKS test for primes step by step in the Forth programming language
You may also check:How to resolve the algorithm String length step by step in the J programming language
You may also check:How to resolve the algorithm Comments step by step in the DWScript programming language
You may also check:How to resolve the algorithm Achilles numbers step by step in the ARM Assembly programming language
You may also check:How to resolve the algorithm Filter step by step in the Lasso programming language