How to resolve the algorithm Pythagorean quadruples step by step in the Amazing Hopper programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Pythagorean quadruples step by step in the Amazing Hopper 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 Amazing Hopper programming language
Source code in the amazing programming language
#include
DEF-MAIN(argv, argc)
SET(N, 2200)
DIM( MUL(MUL(N,N),2) ) AS-ZEROS( temp )
DIM( N ) AS-ZEROS( found )
MSET( a,T1,T2 )
TIC(T1)
SEQ-SPC(1,N,N,a), LET( a := MUL(a,a) )
SET(i,1), SET(r,0)
PERF-UP(i,N,1)
LET( r := ADD( [i] GET( a ), [i:end] CGET(a) ) )
SET-RANGE( r ), SET(temp, 1), CLR-RANGE
NEXT
SET(c,1), SET(s,3), MSET(s1,s2,d)
PERF-UP(c, N, 1)
LET( s1 := s )
s += 2
LET( s2 := s )
LET( d := ADD(c,1) )
PERF-UP(d, N, 1)
COND ( [s1] GET(temp) )
[d] {1} PUT(found)
CEND
s1 += s2
s2 += 2
NEXT
NEXT
TOC(T1, T2), PRNL("Time = ", T2 )
PRN( "Imprimiendo resultados:\n" )
CART( IS-ZERO?( found ) ) MOVE-TO( r )
PRNL( r )
MCLEAR(temp, found, a, r)
END
You may also check:How to resolve the algorithm Execute HQ9+ step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Range extraction step by step in the Go programming language
You may also check:How to resolve the algorithm Multi-base primes step by step in the F# programming language
You may also check:How to resolve the algorithm Loops/Infinite step by step in the Wren programming language
You may also check:How to resolve the algorithm Bitmap/Bézier curves/Cubic step by step in the Lambdatalk programming language