How to resolve the algorithm Averages/Pythagorean means step by step in the Amazing Hopper programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Averages/Pythagorean means step by step in the Amazing Hopper programming language

Table of Contents

Problem Statement

Compute all three of the Pythagorean means of the set of integers 1 through 10 (inclusive). Show that

A (

x

1

, … ,

x

n

) ≥ G (

x

1

, … ,

x

n

) ≥ H (

x

1

, … ,

x

n

)

{\displaystyle A(x_{1},\ldots ,x_{n})\geq G(x_{1},\ldots ,x_{n})\geq H(x_{1},\ldots ,x_{n})}

for this set of positive integers.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Averages/Pythagorean means step by step in the Amazing Hopper programming language

Source code in the amazing programming language

#include 

/* An example of definitions in pseudo-natural language, with synonimous.
   These definitions can be inside a definition file (xxxx.h) */
#define getasinglelistof(_X_)   {_X_},
#synon  getasinglelistof        getalistof
#define integerrandomnumbers    _V1000_=-1,rand array(_V1000_),mulby(10),ceil,
#define randomnumbers           _V1000_=-1,rand array(_V1000_)
#define rememberitin(_X_)       _X_=0,cpy(_X_)
#synon  rememberitin            rememberthisnumbersin
#define rememberas(_X_)         mov(_X_)
#define remember(_X_)           {_X_}
//#synon  remember            with   ---> this exist in HOPPER.H
#defn   nowconsiderthis(_X_)    #ATOM#CMPLX,print
#synon  nowconsiderthis         nowconsider,considerthis,consider,nowputtext,puttext,andprint
#define andprintwithanewline    {"\n"}print
#synon  andprintwithanewline    printwithanewline
//#defn   andprint(_X_)           #ATOM#CMPLX,print
#define putanewline             {"\n"}
#define withanewline            "\n"
#define andprintit              print
#synon  andprintit              printit,andprint
#define showit                  show
#define afterdoingit            emptystack?,not,do{ {"I cannot continue due to retentive data "},throw(1001) }
#synon  afterdoingit            secondly,finally
#define then                    emptystack?do{ {"I cannot continue because data is missing "},throw(1000) }
/* why "#context" and not "#define"?
   becose "#context" need a value in the stack for continue. 
   Internally, "domeanit" tranform to "gosub(calculatearithmeticmean)",
   and "gosub" works only if it finds a data in the stack */
#context  calculatethegeometricmean
#synon    calculatethegeometricmean   calculategeometricmean,getgeometricmean
#context  calculatetheharmonicmean
#synon    calculatetheharmonicmean    calculateharmonicmean,getharmonicmean
#context  calculatearitmethicmean
#synon    calculatearitmethicmean     calculatesinglemean,calculatemean,domeanit

main:
  consider this ("Arithmetic Mean: ")
  get a list of '10,10' integer random numbers; remember this numbers in 'list of numbers';
  then, do mean it, and print with a new line.
  after doing it, consider ("Geometric Mean: "), remember 'list of numbers', calculate the geometric mean;
  then, put a new line, and print it.
  /*
       Okay. This can be a bit long, if we have to write the program;
       But what if we just had to talk, and the language interpreter takes care of the rest?
  */
  secondly, now consider ("Harmonic Mean: "), with 'list of numbers', get harmonic mean, and print with a new line.
  finally, put text ("Original Array:\n"), and print (list of numbers, with a new line)
exit(0)
.locals
calculate aritmethic mean:
  stats(MEAN)
back
calculate the geometric mean:
  stats(GEOMEAN)
back
calculatetheharmonicmean:
  stats(HARMEAN)
back

  

You may also check:How to resolve the algorithm Averages/Root mean square step by step in the APL programming language
You may also check:How to resolve the algorithm Fraction reduction step by step in the Lua programming language
You may also check:How to resolve the algorithm Look-and-say sequence step by step in the Tcl programming language
You may also check:How to resolve the algorithm Find limit of recursion step by step in the Standard ML programming language
You may also check:How to resolve the algorithm Arbitrary-precision integers (included) step by step in the Oz programming language