Prime Number in Rexx

Published on 28 April 2022 (Updated: 18 September 2022)

Prime Number in Rexx

Welcome to the Prime Number in Rexx page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

>/* ARG with source string named in REXX program invocation */
arg number
If (DATATYPE(number, 'W') == 0) then signal err
If (number < 0) then signal err
isPrime = 1
if \((number // 2 = 0) & (number \= 2) | (number == 1)) then
	do
		i = TRUNC(number / 2)
		do while(i > 3)
			if (number // i == 0) then
				isPrime = 0
			i = i - 1
		end
	end
else
	isPrime = 0

if (isPrime == 1) then
	say "Prime"
else
	say "Composite"
;exit

Err:
say 'Usage: please input a non-negative integer'; exit

Prime Number in Rexx was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.