How to resolve the algorithm Pythagorean quadruples step by step in the Raku programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Pythagorean quadruples step by step in the Raku programming language
Table of Contents
Problem Statement
One form of Pythagorean quadruples is (for positive integers a, b, c, and d):
An example:
For positive integers up 2,200 (inclusive), for all values of a, b, c, and d, find (and show here) those values of d that can't be represented. Show the values of d on one line of output (optionally with a title).
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Pythagorean quadruples step by step in the Raku programming language
Source code in the raku programming language
my \N = 2200;
my @sq = (0 .. N)»²;
my @not = False xx N;
@not[0] = True;
(1 .. N).race.map: -> $d {
my $last = 0;
for $d ... ($d/3).ceiling -> $a {
for 1 .. ($a/2).ceiling -> $b {
last if (my $ab = @sq[$a] + @sq[$b]) > @sq[$d];
if (@sq[$d] - $ab).sqrt.narrow ~~ Int {
@not[$d] = True;
$last = 1;
last
}
}
last if $last;
}
}
say @not.grep( *.not, :k );
You may also check:How to resolve the algorithm Magic squares of odd order step by step in the R programming language
You may also check:How to resolve the algorithm Heronian triangles step by step in the Mathematica / Wolfram Language programming language
You may also check:How to resolve the algorithm Undefined values step by step in the Oforth programming language
You may also check:How to resolve the algorithm Pernicious numbers step by step in the Symsyn programming language
You may also check:How to resolve the algorithm Determine if a string is numeric step by step in the Python programming language