How to resolve the algorithm Idoneal numbers step by step in the ALGOL 68 programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Idoneal numbers step by step in the ALGOL 68 programming language
Table of Contents
Problem Statement
Idoneal numbers (also called suitable numbers or convenient numbers) are the positive integers D such that any integer expressible in only one way as x2 ± Dy2 (where x2 is relatively prime to Dy2) is a prime power or twice a prime power. A positive integer n is idoneal if and only if it cannot be written as ab + bc + ac for distinct positive integers a, b, and c with 0 < a < b < c. There are only 65 known iodoneal numbers and is likely that no others exist. If there are others, it has been proven that there are at most, two more, and that no others exist below 1,000,000.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Idoneal numbers step by step in the ALGOL 68 programming language
Source code in the algol programming language
BEGIN # find idoneal numbers - numbers that cannot be written as ab + bc + ac #
# where 0 < a < b < c #
# there are 65 known idoneal numbers #
INT count := 0;
INT max count = 65;
FOR n WHILE count < max count DO
BOOL idoneal := TRUE;
FOR a TO n - 2 WHILE idoneal DO
FOR b FROM a + 1 TO n - 1
WHILE INT ab = a * b;
INT c = ( n - ab ) OVER ( a + b );
INT sum = ab + ( c * ( b + a ) );
sum <= n
AND ( idoneal := c <= b OR sum /= n )
DO SKIP OD
OD;
IF idoneal THEN
print( ( " ", whole( n, -4 ) ) );
IF ( count +:= 1 ) MOD 13 = 0 THEN print( ( newline ) ) FI
FI
OD
END
You may also check:How to resolve the algorithm Eban numbers step by step in the Go programming language
You may also check:How to resolve the algorithm Base64 decode data step by step in the Prolog programming language
You may also check:How to resolve the algorithm Roots of a function step by step in the OCaml programming language
You may also check:How to resolve the algorithm String length step by step in the ReScript programming language
You may also check:How to resolve the algorithm Strip control codes and extended characters from a string step by step in the Erlang programming language