How to resolve the algorithm Idoneal numbers step by step in the Action! programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Idoneal numbers step by step in the Action! 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 Action! programming language
Source code in the action! programming language
;;; find idoneal numbers - numbers that cannot be written as ab + bc + ac
;;; where 0 < a < b < c
;;; there are 65 known idoneal numbers
PROC Main()
CARD count, maxCount, n, a, b, c, ab, sum
BYTE idoneal
count = 0 maxCount = 65
n = 0
WHILE count < maxCount DO
n ==+ 1
idoneal = 1
a = 1
WHILE ( a + 2 ) < n AND idoneal = 1 DO
b = a + 1
DO
ab = a * b
sum = 0
IF ab < n THEN
c = ( n - ab ) / ( a + b )
sum = ab + ( c * ( b + a ) )
IF c > b AND sum = n THEN idoneal = 0 FI
b ==+ 1
FI
UNTIL sum > n OR idoneal = 0 OR ab >= n
OD
a ==+ 1
OD
IF idoneal THEN
Put(' )
IF n < 10 THEN Put(' ) FI
IF n < 100 THEN Put(' ) FI
IF n < 1000 THEN Put(' ) FI
PrintC( n )
count ==+ 1
IF count MOD 13 = 0 THEN PutE() FI
FI
OD
RETURN
You may also check:How to resolve the algorithm Null object step by step in the Sidef programming language
You may also check:How to resolve the algorithm Towers of Hanoi step by step in the 360 Assembly programming language
You may also check:How to resolve the algorithm Sum multiples of 3 and 5 step by step in the Seed7 programming language
You may also check:How to resolve the algorithm Entropy/Narcissist step by step in the zkl programming language
You may also check:How to resolve the algorithm Arithmetic/Integer step by step in the Racket programming language