How to resolve the algorithm Pythagorean quadruples step by step in the J programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Pythagorean quadruples step by step in the J 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 J programming language
Source code in the j programming language
Filter =: (#~`)(`:6)
B =: *: A =: i. >: i. 2200
S1 =: , B +/ B NB. S1 is a raveled table of the sums of squares
S1 =: <:&({:B)Filter S1 NB. remove sums of squares exceeding bound
S1 =: ~. S1 NB. remove duplicate entries
S2 =: , B +/ S1
S2 =: <:&({:B)Filter S2
S2 =: ~. S2
RESULT =: (B -.@:e. S2) # A
RESULT
1 2 4 5 8 10 16 20 32 40 64 80 128 160 256 320 512 640 1024 1280 2048
You may also check:How to resolve the algorithm Zeckendorf number representation step by step in the RPL programming language
You may also check:How to resolve the algorithm Character codes step by step in the Aime programming language
You may also check:How to resolve the algorithm Amicable pairs step by step in the Mathematica / Wolfram Language programming language
You may also check:How to resolve the algorithm Video display modes step by step in the Locomotive Basic programming language
You may also check:How to resolve the algorithm Multisplit step by step in the Bracmat programming language