How to resolve the algorithm Pythagorean quadruples step by step in the 11l programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Pythagorean quadruples step by step in the 11l 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 11l programming language

Source code in the 11l programming language

F quad(top = 2200)
   V r = [0B] * top
   V ab = [0B] * (top * 2)^2
   L(a) 1 .< top
      L(b) a .< top
         ab[a * a + b * b] = 1B
   V s = 3
   L(c) 1 .< top
      (V s1, s, V s2) = (s, s + 2, s + 2)
      L(d) c + 1 .< top
         I ab[s1]
            r[d] = 1B
         s1 += s2
         s2 += 2
   R enumerate(r).filter((i, val) -> !val & i).map((i, val) -> i)

print(quad())

  

You may also check:How to resolve the algorithm Strip whitespace from a string/Top and tail step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm XML/Input step by step in the Ada programming language
You may also check:How to resolve the algorithm Middle three digits step by step in the Seed7 programming language
You may also check:How to resolve the algorithm Strip whitespace from a string/Top and tail step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Return multiple values step by step in the Python programming language