How to resolve the algorithm Factors of an integer step by step in the Plain English programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Factors of an integer step by step in the Plain English programming language

Table of Contents

Problem Statement

Compute the   factors   of a positive integer. These factors are the positive integers by which the number being factored can be divided to yield a positive integer result. (Though the concepts function correctly for zero and negative integers, the set of factors of zero has countably infinite members, and the factors of negative integers can be obtained from the factors of related positive numbers without difficulty;   this task does not require handling of either of these cases). Note that every prime number has two factors:   1   and itself.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Factors of an integer step by step in the Plain English programming language

Source code in the plain programming language

To run:
Start up.
Show the factors of 11.
Show the factors of 21.
Show the factors of 519.
Wait for the escape key.
Shut down.

To show the factors of a number:
Write "The factors of " then the number then ":" on the console.
Find a square root of the number.
Loop.
If a counter is past the square root, write "" on the console; exit.
Divide the number by the counter giving a quotient and a remainder.
If the remainder is 0, show the counter and the quotient.
Repeat.

A factor is a number.

To show a factor and another factor:
If the factor is not the other factor, write "" then the factor then " " then the other factor then " " on the console without advancing; exit.
Write "" then the factor on the console without advancing.

  

You may also check:How to resolve the algorithm Associative array/Merging step by step in the AutoHotkey programming language
You may also check:How to resolve the algorithm Vector products step by step in the C++ programming language
You may also check:How to resolve the algorithm Sequence of primes by trial division step by step in the BASIC256 programming language
You may also check:How to resolve the algorithm Define a primitive data type step by step in the EchoLisp programming language
You may also check:How to resolve the algorithm Evolutionary algorithm step by step in the zkl programming language